1

The following code works fine when the name of the saved wifi profile is one word or has no spaces.

"Belkin" works,

"Belkin.536.guests" works,

"My Network" does not work,

Error is: "There is no such wireless interface on the system."

I have about 15 network profiles on my computer and the only ones that do not cooperate with the code have a space in them. The "ECHO" command works every time correctly so I can see that the variable looks correct.

NETSH WLAN SHOW PROFILES  
SET/P "PROFILE=Enter Profile Name : " 
ECHO Showing Info For : %PROFILE%  
NETSH WLAN SHOW PROFILES NAME=%PROFILE% key=clear 

Please tell me what I am doing wrong.

1
  • 2
    We enclose things with spaces in quotes. NETSH WLAN SHOW PROFILES NAME="%PROFILE%" Commented Jan 29, 2016 at 15:16

4 Answers 4

4

I think you should enclose your strings in quotes. IF you don't do this, every word after a space will be considered like a single command.

Sign up to request clarification or add additional context in comments.

Comments

2

The correct way is: NETSH WLAN SHOW PROFILE NAME="name" key=clear

You are writing PROFILES, but you should write just PROFILE.

Comments

0

NETSH WLAN SHOW PROFILES NAME=%PROFILE% key=clear

If %PROFILE% is My Network then you are executing this command and it thinks "Network" is another parameter:

NETSH WLAN SHOW PROFILES NAME=My Network key=clear

However, if you simply add quotes like this:

NETSH WLAN SHOW PROFILES NAME="%PROFILE%" key=clear

Now you are executing this command:

NETSH WLAN SHOW PROFILES NAME="My Network" key=clear

Comments

0

Use a wildcard or * in your command. For example:

NETSH WLAN SHOW PROFILES NAME="My*"

or to see all your connections (page by page):

NETSH WLAN SHOW PROFILES NAME=*|more

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.