How can i connect to ad-hoc network using CMD?

2

1

I'm trying to connect my computer (PC1) to an existing ad hoc using cmd commands.This ad hoc was created by second computer(PC2),i spend hours to find results but i did find an answers.See this photo to understand me.

I tried these commands :

Netsh wlan export profile  folder=”c:\profiles” name="Profile 1" interface="Wireless Network Connection"


Netsh wlan add profile filename=C:\Users\WirelessUser\Documents\profile1.xml interface="Wireless Network Connection"

But i can't keep my need.

I need some steps to creating a profile for ad hoc (this ad hoc was created by other machine ),or should i use other methods by using cmd ?

Xlint Xms

Posted 2017-12-09T16:40:39.377

Reputation: 121

1What happens if you try to connect it manually? – xavier_fakerat – 2017-12-09T16:48:27.137

Every thing is well , but i need commands for my project. – Xlint Xms – 2017-12-09T17:14:21.393

Answers

3

1- create an XML file and copy/past these lines:

<?xml version="1.0"?>
<WLANProfile xmlns="http://www.microsoft.com/networking/WLAN/profile/v1">
<name>{SSID}</name>
<SSIDConfig>
    <SSID>
        <name>{SSID}</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>

2- replace the keywords {SSID} (occurs two times) and {password} with the desired values

3- call that file in cmd (navigate first to its location):

netsh wlan add profile filename="file_name.xml"

4- then execute this command:

netsh wlan connect name="SSID"

NB: the same SSID used in XML file!

and boom, it will connect!

Note:

1- Pay attention to spelling the SSID (uppercase and lowercase letters)

2- SSID = "hotspot name"

IlyeSudo

Posted 2017-12-09T16:40:39.377

Reputation: 66

At moment every thing is well ,but i have this error: Unable to connect to the network specified by the profile. – Xlint Xms – 2017-12-10T17:25:22.243

Be sure you did this: navigate first to its location – Ramhound – 2017-12-10T19:56:11.820