netsh profile name issue

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
cjtemple
Posts: 4
Joined: 12 Mar 2021 13:02

netsh profile name issue

#1 Post by cjtemple » 12 Mar 2021 13:15

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

Squashman
Expert
Posts: 4268
Joined: 23 Dec 2011 13:59

Re: netsh profile name issue

#2 Post by Squashman » 12 Mar 2021 13:49

Can you show us the output of

netsh wlan show profiles "John Temple's iPhone"

cjtemple
Posts: 4
Joined: 12 Mar 2021 13:02

Re: netsh profile name issue

#3 Post by cjtemple » 12 Mar 2021 22:18

Certainly, scroll down a bit in the first code block.

Squashman
Expert
Posts: 4268
Joined: 23 Dec 2011 13:59

Re: netsh profile name issue

#4 Post by Squashman » 12 Mar 2021 22:51

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.

cjtemple
Posts: 4
Joined: 12 Mar 2021 13:02

Re: netsh profile name issue

#5 Post by cjtemple » 16 Mar 2021 05:03

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.

cjtemple
Posts: 4
Joined: 12 Mar 2021 13:02

Re: netsh profile name issue

#6 Post by cjtemple » 16 Mar 2021 06:34

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.

ShadowThief
Expert
Posts: 1015
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: netsh profile name issue

#7 Post by ShadowThief » 16 Mar 2021 06:58

The standard escape character in batch is ^

Squashman
Expert
Posts: 4268
Joined: 23 Dec 2011 13:59

Re: netsh profile name issue

#8 Post by Squashman » 16 Mar 2021 10:49

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.

Compo
Posts: 527
Joined: 21 Mar 2014 08:50

Re: netsh profile name issue

#9 Post by Compo » 16 Mar 2021 12:41

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.

Post Reply