Modern users are accustomed to a graphical interface, where all settings are hidden behind beautiful icons and clear menus. However, there are situations when the familiar Windows shell crashes, drivers don't initialize correctly, or fine-tuning of the network is required that isn't accessible through the standard settings. This is where the command line comes in—a powerful tool for managing network connections at a low level.
Usage command line The Wi-Fi Command Manage (CMD) tool gives system administrators and advanced users complete control over their wireless adapter. Not only can you connect to an access point, but you can also view saved passwords, clear profile caches, configure static IP addresses, and even create a virtual access point for internet sharing. This is an indispensable skill for diagnosing problems when the graphical interface freezes or malfunctions.
In this guide, we'll cover in detail how to connect to Wi-Fi via CMD, which commands to use to manage profiles, and how to troubleshoot common connection errors. We'll also cover the utility's syntax. netsh, which is the main network configuration tool in Windows, and we'll learn how to create your own scripts to automate connections. Even if you're a beginner, following the instructions will help you master this professional approach to network management.
Preparing the environment and launching the command line
Before entering commands, you must have the appropriate access rights. The Windows operating system restricts changes to network settings for security reasons, so simply launching the console will not allow you to perform the necessary actions. You will need to launch the terminal as administratorTo do this, right-click the Start button and select "Windows PowerShell (Admin)" or "Command Prompt (Admin)." In older versions of Windows, you can search for "cmd" in the search bar, right-click, and select the appropriate option.
After opening a window with a black background, you'll see the path to the system folder. Now you need to check if your computer can see the wireless adapter. Enter the command netsh wlan show interfaces and press Enter. If the adapter is working properly and the drivers are installed, you'll see a list of parameters: status (connected/disconnected), SSID (network name), radio type (802.11n/ac/ax), and signal strength. If you receive an error message or an empty list, the problem may be with the drivers or a physically disconnected Wi-Fi module.
⚠️ Attention: If the command shows "Disabled" or the adapter isn't listed, don't try reinstalling Windows immediately. First, check Device Manager for yellow exclamation marks and ensure the wireless module isn't disabled in the BIOS/UEFI.
For more detailed diagnostics, you can use the command ipconfig /all, which will display complete information about all network interfaces. Look for the "Wireless Network" or "Wireless LAN Adapter" section. It's important to note the presence of an IP address. If the address begins with 169.254.x.x, this means that the computer was unable to obtain an address from the router's DHCP server, and the connection is not actually established, even if the Wi-Fi icon shows the presence of a network.
Search for available networks and analyze the signal
The first step to connecting is to discover nearby access points. The command line allows you to not only see a list of names but also obtain technical information about each network. Enter the command netsh wlan show networks mode=bssidThis instruction will list all visible Wi-Fi networks with details about each access point, including MAC addresses (BSSID), channels, and encryption types.
Why is routine important? BSSIDIn multi-apartment buildings, the same network (for example, "Home_WiFi") can be broadcast by multiple routers or access points to improve coverage. This command will show you which emitter has the best signal. Parameter Signal Displayed as a percentage. Choose the network with the highest percentage for a stable connection. You can also see the security type here: WPA2-Personal, WPA3 or outdated WEP.
- 📶 Signal: Signal level in percentage, a critical parameter for choosing a connection point.
- 🔒 Security: The type of security protocol that your adapter must support.
- 📡 Channel: The channel number on which the network operates (important for interference diagnostics).
- 🏷️ SSID: The name of the wireless network you see in the list of available connections.
If the list of networks is empty, even though Wi-Fi is working on other devices, the Windows wireless network service may be stopped. Check this by entering sc query wlansvcIf the status is not RUNNING, start the service with the command net start wlansvcThis is a common problem after an improper system shutdown or updates.
Creating and saving an XML network profile
Unlike the graphical interface, where you simply select a network and enter a password, the connection process in CMD often requires creating a profile first. A profile is an XML file containing security settings and the network name. This may seem complicated, but this approach provides flexibility and automation. First, let's create a profile file manually or generate a template.
Create a text file named wifi.xml on drive C (to keep the path short, for example, C:\wifi.xml). You need to place the XML structure in it. For a network with WPA2-Personal encryption (the most common option), the file contents should look like this. Note that the tag SSID should contain the name of your network, and in the tag ProtectedNetwork You need to enter a password.
<?xml version="1.0"?><WLANProfile xmlns="http://www.microsoft.com/network/WLAN/Profile/v1">
<name>MyNetwork</name>
<SSIDConfig>
<SSID>
<name>MyNetwork</name>
</SSID>
</SSIDConfig>
<connectionType>ESS</connectionType>
<connectionMode>manual</connectionMode>
<MSM>
<security>
<authEncryption>
<authentication>WPA2PSK</authentication>
<encryption>AES</encryption>
<useOneX>false</useOneX>
</authEncryption>
<sharedKey>
<keyType>passPhrase</keyType>
<protected>false</protected>
<keyMaterial>MyPassword123</keyMaterial>
</sharedKey>
</security>
</MSM>
</WLANProfile>
In this code replace MyNetwork to the name of your network (SSID), and MyPassword123 — with the actual Wi-Fi password. It's important to maintain the case of the letters in the network name. After saving the file, proceed to activating it. If you don't want to mess with XML files, you can use a simpler method using the command netsh wlan add profile by specifying a key, but creating a profile via XML gives more control over parameters such as encryption type.
Connecting to Wi-Fi using commands
Once the profile is created and saved to disk, it needs to be added to the system. Open the command prompt as administrator (if you haven't already) and enter the following command to import the profile: netsh wlan add profile filename="C:\wifi.xml"If the file path contains spaces, quotation marks are required. The system should respond with the message "Profile added successfully."
Now that the system knows about the existence of this network and has the access keys, you can initiate a connection. To do this, use the command netsh wlan connect name="Profile_Name"Please note: the name in the command must match the tag <name> in the XML file, and not necessarily with the SSID, although they are most often identical. If the profile name and SSID match, you can use the command netsh wlan connect ssid="Network_Name".
During the connection process, the system will attempt to associate with the access point. You can monitor the status by re-entering the command netsh wlan show interfacesThe "Status" line should show "Connected." If the status changes to "Disconnected" with an error code, this indicates a problem with the security key or incompatibility of encryption protocols.
☑️ Connection checklist via CMD
Profile Management and Security
Using the command line allows you to effectively manage your accumulated list of networks. Over time, these networks can become numerous, and some may contain errors or be used for tracking purposes. The command netsh wlan show profiles will display a list of all saved profiles on this computer. This is useful for understanding which networks your laptop has previously attempted to connect to.
One of the most requested features for the average user is the ability to view password from an already connected network. The GUI hides the symbols with asterisks, but CMD can reveal them. Enter the command: netsh wlan show profile name="Network_Name" key=clearIn the "Security settings" section, find the "Key Content" field—the password will be displayed there in clear text.
| Team | Description of action | Necessary rights |
|---|---|---|
show profiles |
Shows a list of all saved profiles. | User |
show profile name="X" key=clear |
Displays the network password in clear text. | Administrator |
delete profile name="X" |
Deletes a network profile from memory. | Administrator |
export profile name="X" folder="C:\" |
Exports profile to XML file (without password) | Administrator |
To remove unnecessary profiles, use the command netsh wlan delete profile name="Network_Name"This is useful if you've changed your router password and your computer is trying to connect with the old password, or if you no longer want to automatically connect to a public network at a cafe or airport. Clearing the profile list can also speed up the initial network scan.
⚠️ Attention: Be careful when deleting system network or corporate access point profiles if you work in an office. Deleting a profile WLAN may require re-authorization through the provider portal or the entry of complex certificates.
Diagnosing problems and troubleshooting errors
Even with the correct command syntax, the connection may fail. A typical error is "Unable to connect" or an infinite loop for obtaining an IP address. In such cases, the first step is to reset the network stack. netsh winsock reset resets the Winsock directory to its default state, and netsh int ip reset Overwrites registry keys related to TCP/IP. A computer restart is required after running these commands.
If the problem is with the driver, the command line can also help. In Device Manager, find your Wi-Fi adapter, go to Properties, and in the Details tab, look at the device ID. But it's faster to use the command pnputil /scan-devices, which will force a scan for hardware changes. You can also try disabling and enabling the adapter programmatically: netsh interface set interface "Wi-Fi" disable and then enable.
Sometimes a complete reset of TCP/IP settings helps. Enter the following in sequence:
ipconfig /release
ipconfig /renew
ipconfig /flushdns
This will release the current IP, request a new one, and clear the DNS cache, which will solve problems with accessing websites when Wi-Fi is working.
What to do if the command fails?
If you see an "Access Denied" message, make sure you're running CMD as an administrator. If you see a "Service Not Started" error, check the status of the WLAN AutoConfig service in services.msc.
Automation and creation of connection scripts
The main advantage of using CMD is its automation capabilities. You can create a BAT file that will connect your laptop to your home network immediately after booting, bypassing lengthy checks for other saved networks. Create a text file, rename it to connect_home.bat and paste there the commands that we discussed above.
Example of script content:
@echo offnetsh wlan connect name="Home_WiFi"
echo Connection attempt completed.
pause
Such a script can be placed at startup. However, it's important to keep security in mind: passwords stored in scripts (if you use the XML method, where the password is explicitly written) may be accessible to other users with access to the file system. For home PCs, this is rarely a concern, but in a corporate environment, it's better to use group policies.
Frequently Asked Questions (FAQ)
Is it possible to connect to a hidden network (Hidden SSID) via CMD?
Yes, this is possible. When creating an XML profile, you need to add the tag <hidden>1</hidden> inside the block <SSIDConfig>You'll also need to manually enter the network name, as automatic search won't find it. The connection command remains the same.
Why doesn't the netsh wlan show networks command see my 5 GHz networks?
Most likely, your wireless adapter doesn't support the 5 GHz band, or the driver is configured to only operate in 2.4 GHz mode. Check the adapter's properties in Device Manager, under the "Advanced" tab, and look for the "Mode" or "Wireless Mode" parameter. 802.11ac or Dual Band.
How do I save my password in my profile if it contains special characters?
In an XML file, special characters may need to be escaped, but in most cases for WPA2-PSK it is sufficient to place them inside the tag. <keyMaterial> Unchanged. If you experience parsing errors, try changing the password to a simpler one (letters and numbers only) for testing purposes to rule out a syntax error in the XML.
Do these commands work in Windows 11?
Yes, it is a utility. netsh is a system command and is present in all modern versions of Windows, including Windows 10 and 11. The command line interface in new operating systems remains compatible with the old instructions.
⚠️ Attention: Command interfaces and available parameters may vary slightly depending on the wireless adapter driver version and Windows edition. Always check the command syntax by adding
/?after the command name (for example,netsh wlan connect /?) to see the latest help.