Connecting to a wireless network via Windows command line (CMD) may seem like a daunting task for beginners, but it's actually one of the most reliable ways to manage network connections. This skill is especially useful when the Windows graphical interface isn't working correctly, the adapter drivers are corrupted, or you're setting up a remote computer without desktop access. Unlike the standard connection via the Wi-Fi tray icon, the method using netsh and other commands gives you more control: you can save passwords, manage network profiles, and even diagnose problems without additional utilities.
This article is suitable for both Windows 10/11, as well as for server versions of the system, where the graphical interface is often disabled. We'll cover not only the basic connection commands, but also look at common errors (for example, Error 0x8007048f or absence of networks in the list), as well as alternative methods through PowerShell And WLAN APIIf you're an admin, a systems engineer, or just someone who likes to automate routine tasks, bookmark this guide.
Why Connect to Wi-Fi via CMD: 5 Real Reasons
Many users don't even realize that the command line can replace the graphical interface for Wi-Fi management. Here are some situations where this method becomes indispensable:
- 🖥️ There is no graphical interface: for example, on server versions of Windows (Server 2019/2022) or in mode
Safe Mode with Networking. - 🔧 Driver failures: when the Wi-Fi icon in the tray disappears, but the adapter is physically intact.
- 📡 Connection automation: creating scripts for quickly switching between networks (for example, in the office and at home).
- 🔒 Hidden networks (SSID): connecting to access points that do not broadcast their name.
- 🛠️ Problem diagnosis: commands like
pingoripconfighelp to identify the reason for the lack of Internet.
In addition, knowledge of commands will come in handy if you administer several computers remotely via RDP or SSHIn such cases, opening a graphical interface on each device is inconvenient—it's much easier to send a single command and get a result.
Preparation: Checking the adapter and administrator rights
Before entering any commands, make sure your Wi-Fi adapter is enabled and recognized by the system. To do this:
- Open device Manager (
devmgmt.mscthroughWin + R). - Expand the branch
Network adaptersand find the device with the name Wireless, Wi-Fi or 802.11 (For example, Intel Wi-Fi 6 AX200). - If there is an exclamation mark next to the adapter, update the driver or reinstall it.
Also check if the service is running WLAN AutoConfig:
sc query wlansvc
If the status is not RUNNING, run it with the command:
net start wlansvc
⚠️ Attention: All Wi-Fi management commands require permissions administratorRun CMD as administrator (right-click the icon → "Run as administrator").
The adapter status has been checked in Device Manager|
WLAN AutoConfig service started|
CMD opened as administrator|
The SSID and password of the target network are recorded-->
Basic Wi-Fi Control Commands in CMD
All the magic happens through the utility netsh (Network Shell), which is included with Windows. Below are the key commands with explanations.
| Team | Description | Example |
|---|---|---|
netsh wlan show interfaces |
Shows the current status of the Wi-Fi adapter and connected networks. | |
netsh wlan show networks |
Displays a list of available networks (including hidden ones if the SSID is known). | |
netsh wlan connect name="SSID" |
Connects to the network with the specified name (if the profile is already saved). | |
netsh wlan add profile filename="path.xml" |
Imports a network profile from an XML file (useful for mass deployment). | |
To see full list of commands For netsh wlan, enter:
netsh wlan /?
Step-by-step instructions: connecting to Wi-Fi via CMD
Now let's get practical. Let's say you want to connect to a network named "HomeWiFi" and password "SecurePass123"Here is the algorithm of actions:
Step 1: View available networks
Enter the command to scan the air:
netsh wlan show networks
If your network isn't visible, make sure the adapter is turned on and within range of the router. For hidden networks (where the SSID isn't broadcast), you can skip this step.
Step 2: Create a network profile
Generate an XML file with network settings (replace SSID And keyMaterial to your data):
netsh wlan set profileparameter name="HomeWiFi" connectiontype=ESSID ssidname="HomeWiFi" networktype=infrastructure authentication=WPA2PSK encryption=AES keyMaterial="SecurePass123"
For open networks (no password) use:
netsh wlan set profileparameter name="FreeWiFi" connectiontype=ESSID ssidname="FreeWiFi" networktype=infrastructure authentication=open
Step 3: Connect to the network
Now connect to the profile you just created:
netsh wlan connect name="HomeWiFi"
If everything went well, you will see a message "Connection to the HomeWiFi network successful."
⚠️ Attention: If you are connecting to corporate network with certificates (for example, WPA2-Enterprise), teamsnetshmay not work. In this case, usePowerShellor specialized utilities like WiFi Commander.
What to do if the connect command doesn't work?
If after entering netsh wlan connect an error appears Failed to connect to the network, check:
1. The entered password is correct (case sensitive!).
2. Encryption type (AES/TKIP) - it must match the router settings.
3. Availability of an Internet connection on the router (sometimes the problem is on the provider’s side).
4. Try deleting your profile and creating it again: netsh wlan delete profile name="HomeWiFi"
Troubleshooting: Why Wi-Fi Won't Connect via CMD
Even if you enter the commands correctly, the connection may not work. Let's look at common errors and their solutions:
- 🚫 Error 0x8007048f: service
WLAN AutoConfigdisabled. Run it with the commandnet start wlansvc. - 🔍 Network not found: The adapter doesn't see the access point. Check if Wi-Fi is enabled on the laptop (sometimes it can be turned off by pressing the [key]
Fn + F2/F12). - 🔑 Incorrect passwordWhen creating a profile, make sure your password is correct. To check, delete the profile and create a new one.
- 📡 Weak signal: If the signal level is below 20%, try moving closer to the router or use the command
netsh wlan show interfacesto see the current level.
For in-depth diagnostics, use the following commands:
ping 8.8.8.8
(checking connection to Google DNS)
ipconfig /all
(view current IP settings)
If ping It works, but the internet still doesn't work—the problem is with DNS. Set Google's DNS manually:
netsh interface ip set dns "Wi-Fi" static 8.8.8.8
Alternative methods: PowerShell and WLAN API
If netsh seems outdated, can be used PowerShell — a more modern tool with advanced capabilities. For example, to connect to a network, run:
$profile = [Wlan.WlanProfile]::Create("HomeWiFi", "SecurePass123", [Wlan.WlanAuthentication]::WPA2PSK, [Wlan.WlanEncryption]::AES)
[Wlan.WlanClient]::Connect($profile)
This will require a module NativeWiFi, which can be installed through Install-Module -Name NativeWiFi.
Another option is - WLAN API through C++ or PythonThis is relevant for developers who want to integrate Wi-Fi control into their applications. Here's a Python example:
import pywififrom pywifi import const
wifi = pywifi.PyWiFi()
iface = wifi.interfaces()[0]
iface.connect("HomeWiFi", key="SecurePass123")
These methods are more complex, but provide more flexibility. For example, through PowerShell You can automate connections to different networks depending on your location (home/office).
Saving and exporting Wi-Fi profiles
If you frequently reinstall Windows or set up multiple computers, it's helpful export Wi-Fi profiles into XML files. This will save time when reconfiguring.
To export a profile:
netsh wlan export profile name="HomeWiFi" folder="C:\WiFi_Backup\"
File HomeWiFi.xml will appear in the specified folder. It can be imported on another PC:
netsh wlan add profile filename="C:\WiFi_Backup\HomeWiFi.xml"
Please note: In the XML file the password is stored in in encrypted form, but it can be extracted using utilities like WirelessKeyView (from NirSoft). Never transmit XML profile files over unsecured channels (such as email or instant messaging) – this compromises the security of your network.
⚠️ Attention: Starting from Windows 11 24H2The XML password storage format may change. Before deploying profiles en masse, test them on a test device.
FAQ: Frequently asked questions about connecting to Wi-Fi via CMD
Is it possible to connect to Wi-Fi via CMD without administrator rights?
No, all teams netsh wlan require administrator rights. If you try to run them as a standard user, you will receive an error. Access deniedIn corporate networks, sometimes launching CMD via runas with admin credentials.
How to connect to a hidden network (where the SSID is not broadcast)?
Use the same command netsh wlan connect, but first create a profile specifying the SSID:
netsh wlan add profile filename="C:\hidden.xml" user=current
In the file hidden.xml there should be a block:
<SSIDConfig><SSID>
<name>HiddenNetwork</name>
</SSID>
<nonBroadcast>true</nonBroadcast>
</SSIDConfig>
Why is there no internet access after connecting via CMD?
There are several reasons:
- IP address is missing (check
ipconfig /all). If the address is of the type169.254.x.x- DHCP failure. Runipconfig /releaseAndipconfig /renew. - Blocked by antivirus/firewall. Temporarily disable them to check.
- Problems on the provider's side. Ping them.
8.8.8.8— if the packets arrive, but the websites don’t open, the DNS is to blame.
How to delete all saved Wi-Fi networks using CMD?
List profiles:
netsh wlan show profiles
Then delete the unnecessary ones one by one:
netsh wlan delete profile name="OldNetwork"
To remove all profiles, use the script:
for /f "tokens=2 delims=:" %a in ('netsh wlan show profiles ^| find "All user profiles"') do netsh wlan delete profile name="%a"
Is it possible to change the network connection priority via CMD?
Yes, but not directly. Windows connects to networks in the order they are added. To change the priority:
- Delete all profiles (
netsh wlan delete profile *). - Add them again in the correct order (priority network first).
The alternative is to use Group Policy (gpedit.msc) to control the connection order.