How to Connect to Wi-Fi via CMD: A Complete Guide

Modern operating systems offer convenient graphical interfaces for network management, but sometimes they can be unavailable or malfunction. In situations where the Windows interface freezes, drivers behave unpredictably, or you need to automate the connection process, command lineUsing the console allows direct access to network services and bypasses visual system bugs.

Command line tools in Windows, known as netsh, provides powerful capabilities for administering wireless connections. Netsh commands allow you not only to connect to networks, but also to export profiles with passwords, which is critical when reinstalling the system. This makes the method indispensable for system administrators and advanced users who need full control over the network adapter.

In this article, we'll walk you through the process of setting up Wi-Fi without using a mouse or the Start menu. You'll learn how to scan the air, create new connection profiles, and even restore internet access in Safe Mode when the graphical desktop won't load.

Launch Command Prompt with Administrator Privileges

Any actions with network interfaces require elevated privileges. Normal user mode will prevent the system from making changes to adapter configurations or saving new security profiles. Therefore, the first step is always to launch the terminal as an administrator.

There are several ways to open the required interface. The fastest option is to use the taskbar search or a keyboard shortcut. Win + X, then select "Windows PowerShell (Administrator)" or "Command Prompt (Administrator)". You can also click Win + R, enter cmd and press Ctrl + Shift + Enter to force launch with administrator rights.

Once the window launches, you'll see a standard command prompt. Make sure the window title says "Administrator"; otherwise, subsequent commands will return an access error. This is a basic operating system security requirement. Windows.

Checking the status of the wireless adapter

Before attempting to connect to an access point, ensure the wireless module is active and functioning properly. The command line allows you to quickly diagnose the status of interfaces without opening Device Manager.

To get a list of all network interfaces, enter the command:

netsh interface show interface

In the list that appears, find the row where the "Type" column says "Wireless Network." Look at the "Status" column. If it says "Disabled," the adapter is disabled either software- or physically. If the status is "Connected," you're already connected to the network. For our purposes, we only want to see the "Connected" status or simply the presence of the adapter in the list.

⚠️ Note: If your wireless adapter isn't listed, there may be a driver issue. Try updating them through Device Manager or the pnputil command.

Sometimes the adapter may be hidden or disabled. To enable it, use the command:

netsh interface set interface name="Adapter_Name" admin=enabled

Here Adapter_name should be replaced with the actual name of your device as it appears in the list (e.g., "Wireless Network" or "Wi-Fi"). After completing this procedure, the system will begin searching for available signals.

📊 What's the most common Wi-Fi problem you encounter?
The adapter does not see the network
Constant connection breaks
Low speed
Incorrect password
Drivers are not installed

Scanning for available Wi-Fi networks

Once the adapter is activated, it's time for reconnaissance. The command line allows you to see all available access points within range, their names (SSIDs), encryption types, and signal strength. This is especially useful when the graphical interface doesn't display a list of networks.

To start scanning, enter:

netsh wlan show networks

The system will display a list of 6-8 nearby networks. Each entry will contain the network name (SSID), network type (infrastructure), and authentication type (e.g., WPA2-Personal). The channel and signal strength as a percentage are also indicated.

  • 📡 SSID — the network name that you see in the list of available connections.
  • 🔒 Authentication — protection method (WPA2, WPA3, Open).
  • 📶 Signal — signal level, which is important for choosing the optimal access point.

If the network you need isn't listed, it may be hidden (not broadcasting its SSID) or too far away. If the network is hidden, you'll need to know its exact name to create a profile manually.

Creating and saving a connection profile

To connect to a network, you need to create a profile. A profile is a configuration file containing the network name, security settings, and password. In Windows, these profiles are stored in the registry and used for automatic connections in the future.

The easiest way to create a profile is to use a command with key parameters. The syntax is as follows:

netsh wlan add profile filename="profile.xml"

However, a more direct method of creating a profile on the fly without creating an XML file is more commonly used if you know the password. But the standard netsh Requires XML to initially create a complex profile. To simplify things, you can create an XML file using Notepad.

Create a text file, name it wifi.xml and paste the following template there, replacing the data with your own:

<?xml version="1.0"?>

<WLANProfile xmlns="http://www.microsoft.com/network/WLAN/1">

<name>MyHomeWiFi</name>

<SSIDConfig>

<SSID>

<name>MyHomeWiFi</name>

</SSID>

</SSIDConfig>

<connectionType>infrastructure</connectionType>

<connectionMode>auto</connectionMode>

<MSM>

<security>

<authEncryption>

<authentication>WPA2PSK</authentication>

<encryption>AES</encryption>

<useOneX>false</useOneX>

</authEncryption>

<sharedKey>

<keyType>passPhrase</keyType>

<protected>false</protected>

<keyMaterial>Your_Password_Here</keyMaterial>

</sharedKey>

</security>

</MSM>

</WLANProfile>

After saving the file, enter the add profile command, specifying the path to the file. If the file is located in the root of the C: drive,

netsh wlan add profile filename="C:\wifi.xml"

If the profile is created successfully, the system will confirm with a message. The profile is now saved to your computer's memory and ready for use.

Connecting to the network and managing profiles

Once the profile has been added to the system, you need to initiate a connection. Windows will attempt to connect to the specified access point using the saved encryption settings and security key.

The connection command looks like this:

netsh wlan connect name="Profile_Name" ssid="Network_Name"

Here Profile_Name — this is the name you gave the profile (often the same as the SSID), and Network_Name — This is the exact name of the wireless access point detected during scanning. If the network is hidden, the ssid parameter is still required and must match the name in the profile.

To manage existing profiles, use the command table:

Action Team Description
Show profiles netsh wlan show profiles Displays a list of all saved profiles.
Delete profile netsh wlan delete profile name="Name" Removes the specified profile from the system.
Show password netsh wlan show profile name="Name" key=clear Displays details including security key
Clear profiles netsh wlan delete profile name=* i=Wi-Fi Removes all profiles for the specified interface.
⚠️ Note: The profile deletion command requires an exact name match. A single character error will result in a "Profile not found" message.

It's also useful to know how to view the saved password for a network you've already connected to. Use the command show profile with a key key=clearIn the "Security Settings" section, you will see the "Key Contents" field, where the password will be displayed in clear text.

What to do if the profile is not deleted?

If the system writes "Access denied" when deleting a profile, try stopping the WLAN AutoConfig service (wlansvc) via services.msc, deleting the profile, and then starting the service again.

Network diagnostics and reset

If the connection fails, even with the correct profile, troubleshooting is required. The command line offers tools for resetting the TCP/IP stack and restarting network components, which often resolves adapter freezes.

First, try resetting Winsock and TCP/IP settings:

netsh winsock reset

netsh int ip reset

After running these commands, you must restart your computer. You can also try forcibly disconnecting from the network and reconnecting using the following commands: disconnect And connect in the wlan interface.

  • 🔄 Reset — clears DNS cache and network sockets.
  • 🛠 Diagnostics - team netsh wlan show wlanreport Generates an HTML report of all Wi-Fi events for the last 3 days.
  • 🔌 Restart - sometimes it helps to simply turn the adapter off and on with the command set interface ... admin=disabled and then enabled.

Report generated by the command wlanreport, is saved along the way C:\ProgramData\Microsoft\Windows\WlanReport\wlan-report-latest.htmlThis is a powerful tool for analyzing the causes of connection failures.

☑️ Wi-Fi Diagnostic Checklist

Completed: 0 / 5

Using the command line to manage Wi-Fi may seem complicated at first. Once you learn the basic commands, netsh wlan, you can manage connections faster than through the graphical interface and solve problems that seem insoluble in the normal mode.

How to connect to a hidden network using CMD?

To connect to a hidden network (one that doesn't appear in the list during scanning), you need to create an XML profile manually, as described in the section on creating profiles. In the XML file, in the tag <name> And <SSID><name> Specify the exact network name (SSID). Then in the tag <connectionMode> It's better to set the value manualto prevent the computer from attempting to connect automatically at random. After adding the profile with the command add profile, use the command connect specifying the profile name. The computer will begin actively sending requests to search for this specific network.

Where are Wi-Fi profiles stored in Windows?

Wireless network profiles are stored in a protected part of the Windows registry and in the file system. Physically, the profile files are located in the folder C:\ProgramData\Microsoft\Wlansvc\Profiles\InterfacesHowever, the contents of these files are encrypted and not intended for manual editing. To view, export, or import profiles, always use utilities. netsh, as they handle encryption keys and access rights correctly.

Is it possible to share Wi-Fi via the command line?

Yes, Windows supports the Hosted Network feature, which allows you to turn your laptop into a hotspot. To do this, use the command netsh wlan set hostednetwork mode=allow ssid="Name" key="Password" for setting up and netsh wlan start hostednetwork to launch. However, in recent versions of Windows 10 and 11, this feature has often been replaced by the standard "Mobile Hotspot" feature in Settings, but CMD commands still work on many systems.