Situations where the Windows graphical interface stops responding or works incorrectly are familiar to many system administrators and advanced users. Sometimes the standard Start menu doesn't allow you to find the desired network adapter, and the Wi-Fi icon simply disappears from the system tray. In such cases, the only correct solution is to use the console. The command line provides direct access to network interface management, bypassing possible errors in the operating system's graphical shell.
Usage cmd PowerShell gives you much more control over the connection process. You can not only connect to the access point, but also fine-tune encryption settings, delete old profiles that are interfering with the operation, or even create a script to automatically connect at boot. This is especially useful for Windows 10 And Windows 11, where updates sometimes disrupt standard services.
In this article, we will analyze all the nuances of working with the utility. netshWe'll learn how to scan the airwaves, create new security profiles, and resolve IP address conflicts. You don't need to be a programmer to master these commands—just follow the instructions carefully and understand the logic behind network protocols.
Launch Command Prompt with Administrator Privileges
Before entering any commands, you must gain elevated privileges. Normal user mode will not allow you to make changes to system network settings. The fastest way to open the console is to press the following key combination: Win + X and select "Windows Terminal (Admin)" or "Windows PowerShell (Admin)". If you prefer the classic view, click Win + R, enter cmd and press Ctrl + Shift + Enter.
Once the window opens, you'll see a black or blue screen with a blinking cursor. Make sure the window title says "Administrator." If it doesn't, network management commands may fail with an access error. This is a critical step, as network stack The operating system is protected from unauthorized changes.
⚠️ Note: In newer versions of Windows, PowerShell may be installed by default instead of the classic CMD. Netsh command syntax works identically in both shells, so you can use whichever environment is most convenient for you.
The command line interface may seem intimidating to beginners, but it's highly responsive. Any command entered is executed instantly, allowing for quick diagnosis. If the system stops responding, it's the first sign of deeper issues with the drivers or the adapter itself.
Analysis of available wireless networks
The first step is always reconnaissance. You need to make sure the wireless adapter is enabled and can see nearby access points. To do this, use the scan command. Enter netsh wlan show networks and press Enter. The system will display a list of all detected signals within your antenna's range.
In the resulting list, you'll see the SSID (network name), security type, and signal strength. Pay attention to the "Signal" column. Values above 70% are considered excellent, while values below 40% may indicate an unstable connection. If the network you need isn't listed, it may be hidden or operate in the 5 GHz band, which your adapter doesn't support.
- 📡 SSID — the name of the wireless network that is displayed during the search.
- 🔒 Authentication — authentication type (WPA2-Personal, WPA3, etc.).
- 📶 Signal — percentage of received signal power.
- 📶 Channel — the channel number on which the router operates.
If the list is empty, although the router is definitely working, check the status of the WLAN service. Enter sc query wlansvcIf the status is not "RUNNING", start it with the command sc start wlansvcWithout this service, no wireless connection will be established.
Creating and configuring a connection profile
For the computer to "remember" the network and passwords, you need to create a profile. In the graphical interface, this happens automatically the first time you enter a password. In the console, you'll have to do this manually or via an XML file. The easiest way for an open network is to use the command netsh wlan connect name="NetworkName", if the profile already exists.
To create a new profile with a password, the easiest way is to generate an XML configuration file. However, there's a faster method for standard situations. First, let's create a basic profile: netsh wlan add profile filename="C:\path\to\profile.xml"But more often, users simply want to connect. If the network hasn't been saved previously, the system will prompt you to create a profile when you try to connect, provided you use the correct syntax.
Let's consider creating a profile via XML, as this is the most reliable method for corporate networks or complex configurations. You need to create a text file with the .xml extension and enter the SSID and security key parameters there. It seems complicated, but it gives you complete control over encryption protocols.
<?xml version="1.0"?><WLANProfile xmlns="http://www.microsoft.com/networking/WLAN/profile/v1">
<name>MyHomeWiFi</name>
<SSIDConfig>
<SSID>
<name>MyHomeWiFi</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>YourPasswordHere</keyMaterial>
</sharedKey>
</security>
</MSM>
</WLANProfile>
After saving this code to a file, for example wifi.xml, run the import command: netsh wlan add profile filename="C:\Users\User\Desktop\wifi.xml"If everything went well, the system will notify you that the profile has been added. You can now initiate the connection.
| XML parameter | Description | Example of meaning |
|---|---|---|
| name | Profile name in the system | Home_Net |
| SSID | Wireless network name | TP-Link_Ab12 |
| authentication | Authorization method | WPA2PSK |
| encryption | Data encryption type | AES |
| keyMaterial | Wi-Fi password | SuperSecret123 |
Connecting to the network and managing the session
Once the profile has been created and added to the Windows database, it's time to establish a connection. To do this, use the command netsh wlan connect name="Profile_Name"Important: The profile name must match what you specified in the XML or the previous save, and not necessarily the SSID name, although most often they are identical.
The connection process will involve several steps: network discovery, security key negotiation, and obtaining an IP address from the DHCP server. If you see the message "Connection complete," everything was successful. If the process freezes, there may be a problem with the wireless adapter driver or an incorrect password.
- 🔗 Check the connection status with the command
netsh wlan show interfaces. - 🔑 Make sure the correct security type (WPA2/WPA3) is specified in the profile.
- 📡 Make sure you are within network coverage area.
To disconnect from the network, use the command netsh wlan disconnectThis is useful if you need to forcefully disconnect and reconnect with a different profile. Sometimes, it helps reset a stuck IP address without restarting your computer.
⚠️ Note: When connecting to public networks (cafes, airports) through the console, you won't be able to access the Captive Portal login page until you open a browser. The command line doesn't support interaction with web login forms.
☑️ Checklist before connecting
Diagnostics and removal of old profiles
Over time, a computer accumulates a large number of saved networks. This not only clutters the list but can also cause conflicts if the computer tries to connect to a known but unavailable network instead of a new one. Removing unnecessary profiles is a good system maintenance practice.
To see all saved profiles, enter netsh wlan show profilesYou'll see a list of all networks this PC has ever connected to. To delete a specific profile, use the command netsh wlan delete profile name="Network_Name"If you need to delete all profiles at once, you can use the command netsh wlan delete profile name=* i=Wi-Fi (where Wi-Fi is the interface name).
A common problem is when a computer "sees" the network but fails to connect, returning an IP address acquisition error. In this case, resetting the network stack helps. Enter the following in sequence: netsh int ip reset And netsh winsock resetAfter this, a computer restart is required.
It is also useful to know how to view the saved network password if you have forgotten it, but the computer has connected before. Command netsh wlan show profile name="Network_Name" key=clear will display all parameters, including the security key in the "Key Contents" field.
Hidden Networks (Hidden SSID)
If a network is hidden, it won't show up during scanning. To connect, you need to manually create a profile with the exact SSID and set connectMode="manual" in the settings. The system will search for this network even if it doesn't broadcast its name.
Automating connections via batch files
For those who frequently switch between different networks (for example, between the office and home), it's convenient to create a BAT file. This is a text document containing a set of commands that initiates the connection process with a single click. This saves time and eliminates typing errors.
Create a text file, enter the connection commands there and save it with the extension .bat. For example, a file connect_home.bat may contain a command to connect to a home network, and connect_office.bat — to corporate. Such files must be run as administrator.
@echo offecho Connecting to your home network...
netsh wlan connect name="Home_WiFi"
timeout /t 5
ipconfig /all
pause
This script will not only connect you, but also display detailed information about your current IP address and gateway within 5 seconds, making it convenient for quick diagnostics. You can expand its functionality by adding ping checks to the gateway.
Frequently Asked Questions (FAQ)
Why does the netsh wlan connect command give a "Network not found" error?
Most likely, the profile name in the command does not match the name of the saved profile. Check the exact name via netsh wlan show profilesAlso make sure the network is within range and the adapter is turned on.
Is it possible to connect to 5GHz Wi-Fi via command line?
Yes, you can. The command line doesn't limit the frequency range. If your adapter supports 5 GHz and the network is available, the connection will be successful. However, some older adapters may not see this range at all.
How to find the MAC address of a wireless adapter?
Enter the command ipconfig /all or getmacIn the list of physical addresses, find the one that corresponds to the wireless adapter (usually the name contains the words Wireless or Wi-Fi).
Is it safe to store passwords in XML files?
In the example above, the password is stored in cleartext. For increased security, do not store such files on public drives and delete them immediately after use. In corporate environments, use certificates instead of passwords.