3

I am unable to connect to Wi-Fi using command prompt. I want to connect to Wi-Fi using command prompt as per my requirement. I can't use GUI controls or any other third party tools for this purpose

Here is what I am doing:

  1. I am adding the wi-fi profile using command:

netsh wlan add profile filename="PATH_TO_FILE.XML" interface="Wi-Fi"

Wi-Fi profile file looks like:

<?xml version="1.0"?>
<WLANProfile xmlns="http://www.microsoft.com/networking/WLAN/profile/v1">
    <name>WiFi-ProfileName</name>
    <SSIDConfig>
        <SSID>
            <hex>12346692D57617477617331</hex>
            <name>WiFi-SSID</name>
        </SSID>
        <nonBroadcast>true</nonBroadcast>
    </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>true</protected>
                <keyMaterial>KEY_IS_REMOVED_TO_SHOW_THE_FILE_OF_THE_CONTENT_HERE</keyMaterial>
            </sharedKey>
        </security>
    </MSM>
</WLANProfile>
  1. To connect to Wi-Fi network using I am using command:

netsh wlan connect ssid="WiFi-SSID" name="WiFi-ProfileName" interface="Wi-Fi"

After running this command, command prompt is showing a message that Connection request was completed successfully, but machine is not connecting the Wi-Fi at all.

Am I missing some setting to set any kind of permission or its something else?

Akash
  • 179
  • 1
  • 3
  • 12
  • This looks right to me. One thing you might try is dropping the SSID and interface arguments. Since your profile only has one SSID in it, netsh will use that by default. Assuming you only have one wifi interface, the interface argument is also unnecessary. I tried your setup with my home network and I connected just fine. If you want to make sure you have a correct profile, one thing you can try is using the UI to connect, then using netsh to export the profile. Then you're guaranteed to have a correct profile. – alexcalibur May 19 '15 at 19:56
  • @alexcalibur I have also tried cmd without SSID and Interface, but there is no luck. One thing I noticed, if initially(prior to issue connect cmd) I create a connection to the WI-FI using UI then after that I am able to connect or disconnect to WiFi via command prompt using same commands. _Can you please try by removing your WiFi connection at all by clicking "Forgot This Connection" and then try to connect to it via command prompt by importing the WiFi profile and let me know the outcome_? Which OS is installed on your machine? – Akash May 20 '15 at 15:45
  • sorry I did not do this when you initially asked, I was not available... anyway, I just tried it, and I was still able to connect. Steps: 1. netsh wlan export profile name=HomeNetworkSsid (this produced a Wi-Fi-HomeNetworkSsid.xml) 2. "Forget This Connection" 3. netsh wlan add profile filename=Wi-Fi-HomeNetworkSsid.xml 4. netsh wlan connect name="HomeNetworkSsid" (Connection request was completed successfully, the WiFi icon did not appear in systray for some reason but when I went there myself I was connected). I am on Windows 8.1. Hope this helps. – alexcalibur May 30 '15 at 04:11

0 Answers0