How to use netsh to delete a profile with UTF8 characters?

0

I connected to a W with UTF-8 characters (One of the Doctor Who ones, ┓┏ 凵 =╱⊿┌┬┐ or similar) which clashed terribly with Windows' assumption that UTF-16 is used everywhere.
Now I can't delete it from my network list.

C:\WINDOWS\system32>netsh wlan show profile

Profiles on interface WiFi:

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

User profiles
-------------
    /* Redacted */ 
    All User Profile     : â""â"? å╬µ =â±âS¿â"Oâ"¬â"?
    /* Redacted */ 

C:\WINDOWS\system32>netsh wlan delete profile name="┓┏ 凵 =╱⊿┌┬┐"
Profile "?? ? =??┌┬┐" is not found on any interface.

C:\WINDOWS\system32>netsh wlan delete profile name="â""â"? å╬µ =â±âS¿â"Oâ"¬â"?"
One or more parameters for the command are not correct or missing.

Is it possible to remove it without wiping the other network profiles too?

Lex R

Posted 2014-01-18T15:10:55.843

Reputation: 123

Answers

1

Workaround

You could manually backup all profiles, delete all of them, and finally import everything back. This command will delete all profiles (no matter what the profile names are) by using a wildcard:

netsh wlan delete profile name="*"

Batch automation

The following script will:

  1. Export all profiles, automatically skipping those with unsupported characters in their name.
  2. Wipe all of them.
  3. Import everything saved in step 1.

    @echo off
    cd /d "%~dp0"
    setlocal enabledelayedexpansion
    
    set folder="%cd%\Profiles"
    if not exist "%folder%\" md "%folder%"
    
    for /f "tokens=2 delims=:" %%G in ('netsh wlan show profile') do (
    set name=%%G
    set name=!name:~1!
    netsh wlan export profile name="!name!" folder="%folder%" >nul
    )
    
    netsh wlan delete profile name="*"
    echo.
    for /r "%folder%" %%G in (*.xml) do netsh wlan add profile filename="%%G"
    
    echo. & pause
    exit /b
    

and31415

Posted 2014-01-18T15:10:55.843

Reputation: 13 382