Command Prompt Wi-Fi Secrets: Add, Delete, Connect, All in One Article!

Command Prompt Wi-Fi Secrets: Add, Delete, Connect, All in One Article!

In certain situations, you might need to manually add Wi-Fi profiles, connect to specific Wi-Fi networks via the command prompt, or even set it up as an executable file for one-click addition.

This tutorial will guide you step-by-step through this process.

Adding and Connecting to Wi-Fi Profiles Using Command Prompt

Step 1: Open Command Prompt as Administrator

  • Type cmd in the Windows search bar.
  • Right-click on “Command Prompt” and select “Run as administrator”.

Step 2: Create a New Wi-Fi Profile

  • First, you need to create an XML file containing the Wi-Fi network details. Here’s an example of an XML file:
  • Open Notepad, copy the following content, replace it with your wireless network information, and save it as a .xml file.

XML

<?xml version="1.0"?>
<WLANProfile xmlns="http://www.microsoft.com/networking/WLAN/profile/v1">
    <name>NetworkName</span>name>
    <SSIDConfig>
        <SSID>
            <name>NetworkName</span>name>
        </span>SSID>
    </span>SSIDConfig>
    <connectionType>ESS</span>connectionType>
    <connectionMode>auto</span>connectionMode>
    <MSM>
        <security>
            <authEncryption>
                <authentication>WPA2PSK</span>authentication>
                <encryption>AES</span>encryption>
                <useOneX>false</span>useOneX>
            </span>authEncryption>
            <sharedKey>
                <keyType>passPhrase</span>keyType>
                <protected>false</span>protected>
                <keyMaterial>Password</span>keyMaterial>
            </span>sharedKey>
        </span>security>
    </span>MSM>
</span>WLANProfile>

The following lines of code can be inserted between </span>MSM></span>WLANProfile>.

<MacRandomization xmlns="http://www.microsoft.com/networking/WLAN/profile/v3">
    <enableRandomization>false</enableRandomization>
    <randomizationSeed>779804917</randomizationSeed>
</MacRandomization>

These lines of code are used to configure the MAC address randomization feature in the WLAN profile. Specifically:

  • <MacRandomization xmlns="http://www.microsoft.com/networking/WLAN/profile/v3">: Defines the XML namespace for MAC address randomization.
  • <enableRandomization>false</enableRandomization>: Disables the MAC address randomization feature. If set to true, randomization is enabled.
  • <randomizationSeed>779804917</randomizationSeed>: Sets the seed value for randomization, used to generate random MAC addresses. You can set your own numeric value.

These commands are primarily used to control whether the device uses a randomized MAC address when connecting to a WLAN, to enhance privacy and security.

  • Replace NetworkName with your Wi-Fi network name and Password with the network password.

Step 3: Save the XML File

  • Save the XML file to a location on your computer, for example, C:\WiFiProfile.xml.

Step 4: Add the Wi-Fi Profile

    • Use the command to add the Wi-Fi profile to your computer.
netsh wlan add profile filename="C:\WiFiProfile.xml"

Open Notepad, write this command, save it as a .bat file, and place it in the same folder as the configured XML file. Note the file saving location for the command. You can then directly double-click the executable file to add the wireless network.

netsh wlan add profile filename="D:\WiFi-GUESTWIFI.xml"

Save this line of code as a .bat file. Like this, you can automatically add Wi-Fi by simply inserting a USB drive and double-clicking.

Step 5: Connect to the Wi-Fi Network

    • Use the command to connect to the Wi-Fi network.
netsh wlan connect name="NetworkName"
  • Replace NetworkName with your Wi-Fi network name.

This process will add the Wi-Fi network to your list of known networks and automatically connect to it.

Deleting Multiple Wi-Fi Networks Using Command Prompt

Over time, your computer may store many Wi-Fi network profiles from past connections. If you want to clean up these profiles, you can easily do so using the command prompt.

Step 1: Open Command Prompt as Administrator

  • Type cmd in the Windows search bar.
  • Right-click on “Command Prompt” and select “Run as administrator”.

Step 2: List All Known Wi-Fi Networks

    • Enter the command and press Enter.
netsh wlan show profiles
  • This will display a list of all Wi-Fi networks your computer has connected to.

Step 3: Delete Multiple Wi-Fi Networks

    • This command will delete all known Wi-Fi profiles at once.
netsh wlan delete profile name="*"

Open Notepad, write this command, save it as a .bat file, and you can then directly double-click the executable file to clear all wireless networks.

  • If you want to delete specific networks, you can list them individually:
    • netsh wlan delete profile name="NetworkName1"
    • netsh wlan delete profile name="NetworkName2"
    • netsh wlan delete profile name="NetworkName3"
  • Replace "NetworkName1", "NetworkName2", and "NetworkName3" with the actual names of the networks you want to delete.

Step 4: Confirm Deletion

  • You should see a message confirming that the profiles have been deleted.

WLAN_profile schema elements – Win32 apps | Microsoft Learn

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top