none
Remember radio button selection for different users & open the browser RRS feed

  • Question

  • Hello,

    I have a "working" HTA code but i'd like to add the following into the script , but i cannot manage it to work.
    I'd like to select for each website wich browser i want to use.

    - How to remember the selection of the radio buttons for different users? The location of the script is shared
      If my wife enter this page, the script should auto load here preference radio button settings & so on ..
      I thought by looking of the name of the user in windows to check who is using the script.


    - If you select the first radio button (Internet Explorer) , the website behind the button should be open with IE.
      If you select the "Chrome" radio button , the website behind this button should be open with Chrome

    If someone could help me .... i'm searching for days now :(

    --------------------------------------------------------------------------------------------------------------------

    <html>
    <head>
        <title>test</title>
        <hta:application>
            <scriptlanguage="vbscript">
                Onerrorresumenext
                                    
                            'Internet Explorer
                            Sub iExplorer(url)
                                set shell = createobject("wscript.shell")
                                shell.Run "iexplore " & url
    '                           shell.run(url)
                            EndSub
                            
                            'Google Chrome
                            Sub chrome(url)
                                set shell = createobject("wscript.shell")
                                shell.Run "chrome.exe " & url
                            EndSub
         
    </script>
    </head>

    <body>
        <center>
                <inputtype="radio" name="RadioButton1" ID="RadioButton2" value="iExplorer">Internet Explorer
                <inputtype="radio" name="RadioButton1" ID="RadioButton2" value="Chrome">Chrome            
                    <inputtype='button' class='textfield' value='Wikipedia' onclick='iExplorer("https://www.wikipedia.com")'><br>
                
                <inputtype="radio" name="RadioButton2" ID="RadioButton2" value="iExplorer">Internet Explorer
                <inputtype="radio" name="RadioButton2" ID="RadioButton2" value="Chrome">Chrome        
                    <inputtype='button' class='textfield' value='   Google   ' onclick='iExplorer("https://www.google.com")'><br>
                
                <inputtype="radio" name="RadioButton3" ID="RadioButton2" value="iExplorer">Internet Explorer
                <inputtype="radio" name="RadioButton3" ID="RadioButton2" value="Chrome">Chrome            
                <inputtype='button' class='textfield' value='Facebook' onclick='iExplorer("https://www.facebook.com")'><br>
    </body>
    </html>

    Saturday, November 16, 2019 12:29 PM

All replies

  • Hi Skeleton32,

    You can take a reference of the following code to get the username:

    <script language="vbscript">
    	Sub GetUserName()
    		Set WshNetwork = CreateObject("WScript.Network")	
    		Dim GetUser
    		GetUser = WshNetwork.UserName 
    		Set WshNetwork = Nothing
    		user.innerHTML = "<p>" & GetUser & "</p>"
    	End Sub
    </script>
    
    
    <h1>User</h1>
    <div id="user">
        <script Language="VBScript">
    		GetUserName()
        </script>
    </div>

    And you can save the data to a file to remember the selection of the radio buttons

    Const ForWriting = 2
    	
    Dim objFSO, objFile, strFileName
    strFileName = "textfile.txt"
    
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    	
    Set objFile = objFSO.OpenTextFile(strFileName, ForWriting, true)
    Set objShell = CreateObject("WScript.Shell")
    	
    Sub SubmitValue
    
          datastring = input.Value
          objFile.Write datastring & vbCRLF
    
    End Sub

    Hope it helps and please feel free to talk with us if you have further issue. 

    Best Regards,

    Baker Kong


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click  here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.



    Monday, November 18, 2019 4:11 AM