3

Our company main Wifi ssid is called "#TestRIG". I need to switch SSIDs during the automation test frequently. I tried the command as below.

netsh wlan connect name="#TestRIG"
netsh wlan connect name=^#TestRIG
netsh wlan connect name=\#TestRIG

None of them worked.

C:\Users\admin>netsh wlan connect name=^#TestRIG There is no profile "" assigned to the specified interface.

C:\Users\admin>netsh wlan connect name="#TestRIG" There is no profile "" assigned to the specified interface.

Can anyone help to get the command to escape hash symbol?

Lior Bar-On
  • 10,784
  • 5
  • 34
  • 46
jinhua
  • 31
  • 2
  • 1
    Keep in mind that `name` does not take the SSID. In most cases profile name and SSID are the same, but not always. – Clijsters Apr 28 '16 at 10:25

2 Answers2

1

Not an elegant solution, but you could utilize the built-in "exec" command in netsh referring to a file. Example in PowerShell:

@"
wlan connect name="#TestRIG"
"@ | out-file c:\temp\netsh.txt -encoding ascii

netsh exec c:\temp\netsh.txt
Lior Bar-On
  • 10,784
  • 5
  • 34
  • 46
eldar
  • 11
  • 1
0

I had a similar issue this week and I couldn't find any reference about which escape character to use. I solved using wildcards. It is possible to use '*' or '?' wildcards: e.g:

netsh wlan connect name="*#TestRIG"
netsh wlan connect name="?TestRIG"
  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](https://stackoverflow.com/help/how-to-answer). – Tyler2P May 07 '22 at 17:38