How to Delete a Wi-Fi Network Using the Command Line: A Complete Guide with Examples

Deleting a saved Wi-Fi network via the command line (CMD) is a useful skill for administrators, IT professionals, and regular users who want to clear the network list without a graphical interface. This method is especially relevant if Control Panel or Windows Settings Unavailable due to crashes, viruses, or Group Policy restrictions. Unlike manual removal via the menu, the command line allows you to automate the process, remove networks in batches, and integrate cleanup into scripts.

In this article, you will find not only basic commands for deleting a single network, but also advanced scenarios: how to delete all saved networks at once, how to export a list of networks for backup, and what to do if the command doesn't work. We'll also cover common errors and alternative tools—from PowerShell to third-party utilities.

Why delete Wi-Fi networks via command line?

The Windows graphical interface offers an easy way to manage networks, but the command line has undeniable advantages:

  • 🔧 Automation: commands can be embedded in .bat-files or scripts PowerShell for mass deletion of networks on multiple PCs.
  • 🛡️ Security: Removing "unnecessary" networks reduces the risk of connecting to fake access points (for example, Evil Twin).
  • 🖥️ Remote control: Administrators can clear networks on remote machines via PsExec or WinRM.
  • 🐛 Bypassing failures: If netsh or wlan modules are damaged, alternative commands (for example, through WMI) can save the situation.

In addition, some networks (especially corporate ones) 802.1X-authentication) can get stuck in profiles and interfere with connecting to updated access points. Their removal through CMD often solves the problem without reinstalling drivers.

📊 How often do you clear the list of saved Wi-Fi networks?
Never cleaned
Once a year
When changing the router
Regularly (once a month)

Preparation: Checking Current Wi-Fi Profiles

Before deleting networks, you need to know their exact names (SSID). To do this, use the command:

netsh wlan show profiles

It will list all saved networks in the format:

User profiles

All user profiles: Network_Name_1

Network_Name_2

Starbucks_WiFi

Office_5GHz

⚠️ Attention: Network names (SSID) are case sensitive! If you specify in the command "starbucks_wifi" instead of "Starbucks_WiFi", deleting won't work.

To see detailed information about a specific network (including the security type and key, if saved), run:

netsh wlan show profile name="Network_Name" key=clear

This command will show the password in clear text (parameter key=clear), which is useful for backup before deletion.

Check the list of networks with the command `netsh wlan show profiles`

Write down the exact names (SSID) target networks

Save passwords (if needed) with the `key=clear` parameter

Close programs that use the network (browsers, instant messengers) -->

Basic Method: Deleting a Single Wi-Fi Network

To delete a specific network, use the command:

netsh wlan delete profile name="Network_Name"

Examples:

  • 📶 Network deletion "Office_5GHz":
    netsh wlan delete profile name="Office_5GHz"
  • 🏠 Removing a home network with spaces:
    netsh wlan delete profile name="My Home Network"

If the network name contains special characters (eg. "Café#WiFi"), enclose it in double quotes:

netsh wlan delete profile name="Café#WiFi"
⚠️ AttentionAfter deleting a profile, Windows may automatically connect to another available network from the list. To prevent this, disable this setting. Automatic connection V Wi-Fi parameters in advance.

Advanced Scenarios: Bulk Deletion and Alternative Commands

To remove all saved networks use the script in CMD:

for /f "tokens=2 delims=:" %a in ('netsh wlan show profiles ^| findstr "All user profiles"') do (

for /f "tokens=*" %b in ('netsh wlan show profiles ^| findstr /v "All user profiles" ^| findstr /v "-----" ^| findstr /v "^$"') do (

netsh wlan delete profile name="%b"

)

)

This script:

  1. Gets a list of all profiles.
  2. Excludes service lines ("-----", empty lines).
  3. Deletes each profile one by one.

For PowerShell similar code looks like this:

(netsh wlan show profiles) -match 'All user profiles:' | ForEach-Object {

$profiles = ($_ -split ':')[1].Trim()

$profiles -split "`n" | Where-Object { $_ } | ForEach-Object {

netsh wlan delete profile name="$_"

}

}

Alternative method via WMI (works even if netsh damaged):

Get-WmiObject -Namespace "root\WLAN\v200" -Class MSFT_WLAN_Profile | ForEach-Object { $_.Delete() }
Method Advantages Flaws
netsh wlan delete Simplicity, works on all versions of Windows Does not remove networks with spaces without quotes
Script CMD (cycle for) Bulk deletion, no need PowerShell Complex syntax for beginners
PowerShell + netsh Flexibility, error handling Requires administrator rights
WMI Works when damaged netsh Slower, complex syntax
What to do if the command freezes?

If the `netsh wlan delete` command hangs while running, the cause may be:

1. Network occupancy — disable all active connections via `netsh interface set interface "Wi-Fi" admin=disable`.

2. Profile damage - try deleting it through device Manager (remove the Wi-Fi adapter and restart your PC).

3. Conflict of services - restart the service WLAN AutoConfig:

```cmd

net stop wlansvc

net start wlansvc

```

Common mistakes and their solutions

When deleting Wi-Fi networks via the command line, users often encounter errors. Here are the most common ones and how to fix them:

  • Error: "Profile not found"
    🔹 Cause: Typo in network name or incorrect case.
    🔹 Solution: copy the network name from the output netsh wlan show profiles and paste it into the command.
  • Error: "Access Denied"
    🔹 Cause: insufficient rights (need to run) CMD from the administrator).
    🔹 Solution: right click on Command lineRun as administrator.
  • Error: "The WLAN Automatic Configuration service is not running."
    🔹 Cause: service disabled wlansvc.
    🔹 Solution:
    sc config wlansvc start=auto
    

    net start wlansvc

  • Error: "The profile cannot be deleted because it is in use."
    🔹 Cause: the network is currently active.
    🔹 Solution: Disable Wi-Fi physically or via command:
    netsh interface set interface "Wi-Fi" admin=disable

If the error persists, check the integrity of your system files:

sfc /scannow

dism /online /cleanup-image /restorehealth

Alternative Tools: When CMD Fails

If the standard commands don't work, try these methods:

  • 🔄 Reset network settings:
    In Windows 10/11, open Settings → Network & Internet → Status → Network resetThis will remove All network profiles (Wi-Fi, Ethernet, VPN).
  • 🛠️ Third-party utilities:
    🔹 WiFi Profile Manager — graphical interface for profile management.
    🔹 NetSetMan — allows you to export/import networks.
  • 📜 Manual removal from the registry:
    🔹 Open regedit and go to:
    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\Profiles

    🔹 Delete keys corresponding to unnecessary networks (make a backup copy of the registry first!).

For corporate networks with 802.1X (For example, EAP-TLS) it may be necessary to remove certificates through certmgr.msc or group policy.

⚠️ AttentionDeleting registry keys without a backup can result in the loss of all network settings, including Ethernet connections. Use this method only if other methods have failed.

How to restore a deleted network?

If you accidentally deleted the network you need, you can restore it in two ways:

  1. Reconnect:
    🔹 Find the network in the list of available ones and enter the password (if known).
    🔹 If you don't know the password, check the sticker on your router or ask your network administrator for it.
  2. Restore from backup:
    🔹 If you exported profiles in advance (see the section about netsh wlan export), import them back:
    netsh wlan add profile filename="C:\backup\Office_5GHz.xml"

    🔹 For bulk import, use the script:
    for %f in (C:\backup\*.xml) do netsh wlan add profile filename="%f"

To avoid data loss, export profiles regularly:

netsh wlan export profile folder="C:\WiFi_Backup\"

This command will save all networks in the format .xml in the specified folder. Files can be edited manually (for example, to change a password) or transferred to other computers.

FAQ: Frequently asked questions about deleting Wi-Fi networks

Is it possible to delete a network I'm currently connected to?

No, an active connection prevents profile deletion. First, disconnect from the network via the Wi-Fi icon in the system tray or by using the command:

netsh interface set interface "Wi-Fi" admin=disable

After deleting the profile, the adapter can be re-enabled:

netsh interface set interface "Wi-Fi" admin=enable
How do I delete a network if its name contains Cyrillic characters or emojis?

Use double quotes and the exact name from the output netsh wlan show profiles. For example:

netsh wlan delete profile name="Cafe☕_WiFi"

If the command doesn't work, try replacing the emoji with their text equivalents (e.g. Cafe_WiFi).

Why does a network appear in the list again after being deleted?

This is due to the function Windows Connect Now (WCN), which automatically restores some profiles. To disable it:

  1. Open services.msc.
  2. Find a service Windows Connect Now - Config Registrar.
  3. Stop it and set the startup type Manually.

Also check your router settings - some models (for example, TP-Link or ASUS) send profiles to devices via WPS.

How to delete networks on Mac or Linux?

IN macOS use the command:

networksetup -removepreferredwirelessnetwork en0 "NetworkName"

IN Linux (For example, Ubuntu):

nmcli connection delete id "Network_Name"

For Android you will need a license root or ADB commands.

Is it possible to delete networks on all devices in the house at once?

Yes, but you need access to the router. Log in to the web interface (usually at 192.168.1.1) And:

  1. Change SSID networks (for example, add the suffix _new).
  2. All devices will lose connection and be forced to reconnect.

The alternative is to turn it off WPS And Wi-Fi Protected Setup in the router settings to prevent automatic profile restoration.