Connecting to Wifi in Windows CMD

1.5k views Asked by At

I'v been poking around the internet for the past hour and a half trying to find a windows command similar to wifi connect ssid="YOURSSID" passcode="YOURPASSCODE", and I cant seem to find it! I found wlan, but that has something to do with profiles, and stuff. I don't want to create any profiles, or refrence them! I just want to run the command on its own. Thanks!

2

There are 2 answers

0
HighTechGeek On

This might get you started...

netsh wlan connect ssid=SSID1

UPDATE: Apparently this requires a profile.

0
Benjamin2002 On

You need a xml file that has the SSID and password.

<?xml version="1.0"?>
<WLANProfile xmlns="http://www.microsoft.com/networking/WLAN/profile/v1">
    <name>{example}</name>
    <SSIDConfig>
        <SSID>
            <hex>{6578616d706c65}</hex>
            <name>{example}</name>
        </SSID>
    </SSIDConfig>
    <connectionType>ESS</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>{password}</keyMaterial>
            </sharedKey>
        </security>
    </MSM>
    <MacRandomization 
xmlns="http://www.microsoft.com/networking/WLAN/profile/v3">
        <enableRandomization>false</enableRandomization>
    </MacRandomization>
</WLANProfile>

Fill in the {6578616d706c65}, {example}, {example} and {password} with your own information. {6578616d706c65} is the Hex of example, click here to convert ASCII to HEX.

Make sure you use the correct format, windows WILL NOT accept even there's one more space at the end.

click here to download example.xml and other files.




If you want to use pure cmd to connect (without changing the {password} manually), keep reading


To do this, you will need 36 xml files with a-z and 0-9.

click here to download the 36 files and example.xml.

First you need to separate example.xml into 3 parts, the first part is from <?xml version="1.0"?> to <keyMaterial>. Name that to T.xml.

The second part is the password.

The third part is from </keyMaterial> to the end (</WLANProfile>) make sure you don't forget the line break after </WLANProfile>. Name that to B.xml.

Then you will use the copy command to combine the files.

The code should look like this

copy /y C:\T.xml + C:\keyMaterial\p.xml + C:\keyMaterial\a.xml + C:\keyMaterial\s.xml + C:\keyMaterial\s.xml + C:\keyMaterial\w.xml + C:\keyMaterial\o.xml + C:\keyMaterial\r.xml + C:\keyMaterial\d.xml + C:\B.xml C:\example.xml /B
netsh wlan add profile filename="C:\example.xml" user=all
netsh wlan connect example

Finally, you can check if you're connected by running ping google.com.