How to set up Wi-Fi via the command line: a step-by-step guide

Situations where standard network setup methods are unavailable are common among system administrators and advanced users. Sometimes the operating system's graphical interface is damaged, the remote machine lacks access to the control panel, or you need to deploy a network on a device with minimal pre-installed software. It's in these situations that knowing how to set up Wi-Fi via the command line becomes a real lifesaver.

Using the console allows you to not only launch an access point but also fine-tune security settings, limit the number of connections, or perform advanced driver diagnostics. This powerful tool gives you complete control over your computer or laptop's network adapter. Unlike graphical shells, the command line responds instantly and doesn't require a service restart for changes to take effect.

In this article, we'll cover every step of creating a virtual router in Windows, from checking for technology support to troubleshooting common errors. You'll learn how to write simple scripts to automate the process and understand the principles of command-level security protocols. This knowledge will give you confidence in even the most complex network configurations.

Checking virtual network mode support

Before entering complex commands, you need to ensure that your hardware and installed drivers are capable of supporting the hosted network feature. Not every network adapter, even if it receives a signal correctly, can broadcast it. To check this, use a special diagnostic command that outputs a detailed driver status report.

Open the console with administrator rights and enter the query to display driver information. In the resulting list, find the line responsible for hosted network support. If it says "Yes," then your device is compatible. completely ready to work in access point mode. Otherwise, you'll need to update your drivers or replace the network module with a more modern one.

netsh wlan show drivers

It's worth noting that in the latest versions of Windows 10 and 11, Microsoft has introduced a new "Mobile Hotspot" feature, which may conflict with classic configuration methods via netsh. If you plan to use console commands, ensure the mobile hotspot feature is disabled in the default system settings.

⚠️ Important: If the driver report indicates that virtual network support is not available, do not attempt to force the access point to be created, as this will result in connection errors. In this case, the only solution is to install the original drivers from the laptop or motherboard manufacturer's website.

Also, pay attention to the driver version: older versions may not support modern WPA2-PSK encryption standards. It is recommended to use drivers released no earlier than 2015 to ensure stable operation of the protocol. 802.11ac or newer.

📊 What version of Windows do you use to set up Wi-Fi?
Windows 7
Windows 8.1
Windows 10
Windows 11
Other OS

Creating and configuring a wireless network

After successfully verifying the drivers, you can proceed to creating the network. The setup process is divided into several logical steps: defining the network name (SSID), selecting the encryption type, and setting the password. All these parameters are set with a single command that registers the new profile in the system.

The key here is choosing a network name. It will be displayed on all devices accessing the internet. Use Latin characters for the network name to avoid encoding issues on older smartphones or tablets. The password should be complex but easy to enter on a mobile device.

netsh wlan set hostednetwork mode=allow ssid=MyNetworkName key=MyPassword123 keyUsage=persistent

In this command the parameter mode=allow allows the hosted network to start, ssid specifies the visible name, and key sets the access password. Argument keyUsage=persistent Saves your password in the system's memory so you don't have to re-enter it every time you restart your computer. If you want to change your username or password in the future, simply repeat the command with the new information.

☑️ Check network settings

Completed: 0 / 4

It's important to understand that a network created this way is disabled by default. The system only remembers the configuration but does not activate the radio module to broadcast a signal. To start it, you'll need to run a separate command, which will be discussed in the next section.

Starting an access point and stopping distribution

Activation of the created profile occurs immediately after entering the corresponding command. As soon as you press Enter, the operating system will attempt to launch the virtual adapter. If successful, a status message will appear indicating that the hosted network is running and displaying the name of the created network.

netsh wlan start hostednetwork

Once launched, your computer will begin broadcasting a Wi-Fi signal. Other devices will be able to find the network by name. MyNetworkName (or the one you specified) and connect to it by entering the password. However, at this stage, the internet will not work on the connected devices, as we haven't yet configured traffic forwarding.

To stop broadcasting, use a symmetric command. This is useful when you're finishing work or want to temporarily hide the network from prying eyes without deleting the settings. Stopping the network doesn't delete the profile, so you can restart it at any time.

netsh wlan stop hostednetwork
⚠️ Note: After restarting the operating system, the created access point will not start automatically. You will need to manually enter the startup command each time or create a special batch file to automate this process.
How to create a bat file for quick launch?

Create a text file, paste the launch command into it, save it with the .bat extension, and run it as administrator. This will reduce setup time to a single click.

Setting up Internet access sharing (NAT)

The most common problem users encounter after launching a network is the lack of internet access on connected devices. The computer has created an "island" but hasn't connected it to the "big world." To fix this, you need to configure traffic forwarding through a network adapter that already has internet access (Ethernet or primary Wi-Fi).

To do this, go to the Network Connections control panel. Find your primary connection, the one your computer uses to connect to the internet. Right-click it, select "Properties," then go to the "Sharing" tab. Here, check the box next to "Allow other network users to connect through this computer's Internet connection."

In the "Home networking connection" drop-down list, select the virtual adapter you created earlier. It's usually named "Local Area Connection" with a specific number or has "Microsoft Hosted Network Virtual Adapter" in its name. After applying the settings, the system may briefly disconnect to refresh the settings.

Parameter Value for the main adapter Value for virtual
IP address Dynamic (from router) 192.168.137.1 (gateway)
Subnet mask 255.255.255.0 255.255.255.0
Default Gateway ISP router address Not filled in
DNS Automatically 8.8.8.8 (optional)

If internet access doesn't appear on your phones after enabling shared internet access, try disabling and re-enabling your primary network connection. Sometimes the system needs time to reassign addresses and activate the service. NAT (Network Address Translation).

View information about connected devices

Once the network is up and running and other devices are connected, the administrator often needs to know who is connected to the access point. The command line allows you to obtain detailed information about clients, including their MAC addresses and signal strength.

To obtain a list of connected users, use the show hosted network status command. The report will display the number of current clients and their physical addresses. This information is useful for monitoring unauthorized access.

netsh wlan show hostednetwork

In the command output, you'll see a "Clients" section listing all active connections. If the number of clients is zero, either no one is connected or the devices are in sleep mode. MAC addresses allow you to identify specific devices if you're tracking them.

It's important to remember that this command only shows devices that have successfully authenticated and received an IP address. Devices that simply see the network but haven't entered a password won't be displayed in this list. For a more in-depth traffic analysis, specialized packet sniffers are required.

Troubleshooting and common errors

Despite its apparent simplicity, the setup process can encounter technical obstacles. One of the most common errors is the message "The hosted network could not be started. The group or resource is not in the correct state." This often indicates issues with drivers or Windows services.

First, check the Internet Connection Sharing (ICS) service. It should be running and set to Automatic. If the service is disabled, the system will not be able to physically share the internet connection, even if the virtual network is active.

⚠️ Note: Network settings interfaces and service names may vary slightly depending on your Windows version and installed security updates. If you can't find the item you need, consult the official Microsoft documentation for your specific OS build.

Problems can also be caused by the adapter's power-saving settings. Windows may try to disable the Wi-Fi module to save power, which causes the connection to drop. Go to Device Manager, find your wireless adapter, open its properties, and in the "Power Management" tab, uncheck the box next to "Allow the device to turn off."

Automating the process through scripts

For those who frequently deploy temporary networks, entering commands each time can be tedious. Windows allows you to create batch files (.bat) that perform a series of actions with a single click. This is especially useful for system administrators working with multiple machines.

Create a text file, enter the necessary commands, and save it with the .bat extension. You must run this file as administrator, otherwise the commands will not execute. You can create two files: one for creating and starting the network, and one for stopping it.

@echo off

netsh wlan set hostednetwork mode=allow ssid=OfficeWiFi key=SecurePass123

netsh wlan start hostednetwork

echo Network launched successfully!

pause

This approach not only saves time but also minimizes the risk of typos when entering long passwords or network names. You can also add network status check commands to the script to ensure the launch was successful before notifying your colleagues that the access point is ready.

How to make the network start with Windows?

To run it automatically at system startup, place the created bat file in the startup folder. Press Win+R, enter shell:startup and move the file there. However, keep in mind that this will require administrator privileges, so the standard startup mechanism may prompt you for UAC confirmation.

Is it possible to distribute Wi-Fi if the computer is connected via Wi-Fi?

Yes, this is possible if your network adapter supports both client and access point mode (Dual Band or virtualization). However, the speed may be lower than with a wired connection, as the channel will be split between receiving and transmitting data.

What is the maximum range of this access point?

The range depends entirely on the antenna power of your laptop or PC and cannot be increased by software. Typically, it's 10 to 30 meters indoors, comparable to a typical mid-range router.

Is it safe to use this method in public places?

Using WPA2-PSK encryption provides a basic level of protection, but in public places there is always a risk of man-in-the-middle attacks. For critical data, it is recommended to use additional security measures, such as a VPN.