I'm new in scripting. I need the code to receive some arguments and execute it in hidden cmd in HTA.

the command to execute is netsh wlan set hosted mode=allow ssid="name" key="pwd"

Here i want to get "name" and "pwd" from submit box and execute the above command in hidden hta.

I made it, but not working properly. See

 <script language="VBScript" type="text/vbscript">
set objShell = CreateObject("WScript.Shell")
strOut=""

sub StartProgram
cmdarg="%comspec% /c netsh wlan set hosted mode=allow ssid=" & T1.value "key=" & T2.value
 iReturn=objShell.Run(cmdarg, 0, True)
If iReturn = 0 Then
    MsgBox "Success"
Else
     MsgBox "Cannot Start" 
End If
TraceOut.innerHTML= strOut
end sub
</script>
有帮助吗?

解决方案

I don't know if this is the whole problem, but at the very least:

cmdarg="%comspec% /c netsh wlan set hosted mode=allow ssid=" & T1.value "key=" & T2.value

should be

cmdarg="%comspec% /c netsh wlan set hosted mode=allow ssid=" & T1.value & " key=" & T2.value

In other words, you left an ampersand out after T1.value, and left a space out before key=.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top