Page 1 of 1

netsh profile name issue

Posted: 12 Mar 2021 13:15
by cjtemple
I am working on a one liner to test out a larger project but I am running into issues with profile names. Show profiles has the profile name but when I try to use it I get an error that profile doesn't exist (or at least that is how I interpret the message).
This is run from an elevated command prompt.

Code: Select all

C:\WINDOWS\system32>netsh wlan show profiles

Profiles on interface Wi-Fi:

Group policy profiles (read only)
---------------------------------
    <None>

User profiles
-------------
    All User Profile     : John Temple's iPhone
    All User Profile     : Macworld-5G
    All User Profile     : Temple-Oasis


C:\WINDOWS\system32>netsh wlan connect name="John Temple's iPhone" ssid="John Temple's iPhone" interface="Wi-Fi"
There is no profile "John Temple's iPhone" assigned to the specified interface.
The sticky says that I should include this as well when I am looking for help.

Code: Select all

 INFO.BAT version 1.5
--------------------------------------------------------------------------------
Windows version        :  Microsoft Windows [Version 10.0.18363.1379]
Product name           :  Windows 10 Education, 64 bit
Performance indicators :  Processor Cores: 12      Visible RAM: 33469488 kilobytes

Date/Time format       :  (mm/dd/yy)  Fri 03/12/2021  13:57:45.70
__APPDIR__             :  C:\WINDOWS\system32\
ComSpec                :  C:\WINDOWS\system32\cmd.exe
PathExt                :  .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
Extensions             :  system: Enabled   user: Disabled
Delayed expansion      :  system: Disabled  user: Disabled
Locale name            :  en-US       Code Pages: OEM  437    ANSI 1252
DIR  format            :  03/04/2021  06:37 AM     5,100,273,664 pagefile.sys
Permissions            :  Elevated Admin=Yes, Admin group=Yes

                          Missing from the tool collection:  debug

Re: netsh profile name issue

Posted: 12 Mar 2021 13:49
by Squashman
Can you show us the output of

netsh wlan show profiles "John Temple's iPhone"

Re: netsh profile name issue

Posted: 12 Mar 2021 22:18
by cjtemple
Certainly, scroll down a bit in the first code block.

Re: netsh profile name issue

Posted: 12 Mar 2021 22:51
by Squashman
cjtemple wrote:
12 Mar 2021 22:18
Certainly, scroll down a bit in the first code block.
No it is not. Run the command I requested and provide the output.

Re: netsh profile name issue

Posted: 16 Mar 2021 05:03
by cjtemple
Ah, sorry about that. I see you wanted me to show that profile explicitly.

Code: Select all

C:\WINDOWS\system32>netsh wlan show profiles "John Temple's iPhone"
Profile "John Temple's iPhone" is not found on the system.

Re: netsh profile name issue

Posted: 16 Mar 2021 06:34
by cjtemple
I did a little more testing and debugging. Found it was the apostrophe that was throwing things off. I renamed my network for now. At some point I will have to go about getting it to escape that character. I am pretty sure I tried the typical \ escape character. There is a workaround by using a wildcard in place of the apostrophe but I don't really like that idea. All though it is easy to change the network name for now in a test environment. What if I run into a similar issue out in the real world? You can't always just change the name of the network.

Re: netsh profile name issue

Posted: 16 Mar 2021 06:58
by ShadowThief
The standard escape character in batch is ^

Re: netsh profile name issue

Posted: 16 Mar 2021 10:49
by Squashman
The problem is most likely that the apostrophe is a different unicode character instead of the standard ascii. Which pretty much confirms much suspicion when you didn't get any output. That is what I found from my Google Searches anyways.

Re: netsh profile name issue

Posted: 16 Mar 2021 12:41
by Compo
Whilst you've now created a workaround, by renaming the profile, the apostrophe was almost certainly your issue.

The simplest way to check that character, would be to run your command in a unicode cmd.exe insance.

Code: Select all

cmd /u /d /c "netsh wlan show profiles"
You will almost certainly find that is reports:

Code: Select all

All User Profile     : John Temple’s iPhone
Armed with the confirmation that it is not a dumb, (straight), quote, but a smart, (curly), quote, you should be able to use your command in that, or a standard cmd.exe instance using that character. You could also change the codepage to one which has more characters in its set, like 1252, or 65001.

Code: Select all

netsh wlan show profiles name="John Temple’s iPhone"
You may however find in the output provided, that the Profile's Name, and SSID, (if you thought it was the same as the the Name), do not match. Using a codepage of 1252, or 65001, the Name may show with the correct character, but the SSID may show it as ’.

Inevitably, if you intend to use cmd.exe to interact with your connections, the wisest way would be to ensure that the assigned strings do not use characters from the non standard character set. Although often you have little control of the assigned SSID.