How to connect to Wi-Fi using only CMD?

How to connect to a new Wi-Fi, enter the password using CMD?

For my school project, I decided to make the WiFi_manager program using cmd.

I know to display all WiFi networks (in cmd):

netsh wlan show networks 

Now let me say that I want to connect to a WiFi network that I have never connected to before. And this WiFi does not add any profiles.

But I know the WiFi password.

1) What will be the command line for this.

Based on the Wi-Fi network information below:

 SSID 3 : Ismail Network type : Infrastructure Authentication : WPA-Personal Encryption : CCMP and password is "Thanks_bro". 

I’m looking for this question already in Google, but none of them speak correctly, and most of them are connected with hacking and connecting WiFi without a password, etc. So I sent this question to the best programmers here to answer!

If this is not possible, can we use C ++?

+5
source share
2 answers

So you already know netsh wlan

If you enter it, you will get a list of possible commands. One of them is add .

If you enter netsh wlan add , you get another list of possible subcommands. One of them is profile .

If you enter netsh wlan add profile , you will get a detailed explanation of all the possible options. One of the necessary parameters is an XML file containing profile information.

So how to get such an XML file? Go back to netsh wlan and learn the keywords. There is export .

If you enter netsh wlan export , you will get another list of possible subcommands. One of them is profile . It creates XML in your local directory containing the necessary information for your current WiFi connection.

If you like to enter the password in clear text, you also need to add the key=clear parameter. Make the whole team

 netsh wlan export profile key=clear 

Here is an example that already contains the required placeholders

 <?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> 

Just replace the keywords {SSID} (occurs twice) and {password} with the desired values ​​and import this file by calling

 netsh wlan add profile filename="myProfile.xml" 
+6
source

Basic netsh wlan ? on the command line shows that there is a netsh wlan connect . However, this command seems to require an existing β€œprofile”; you will need to create this using netsh wlan add .
Details remain as an exercise for the reader. (After all, this is homework.)

C / C ++ has an example WLAN client using the Windows API included in the Windows SDK. I found this by searching for wlanclient msdn page here .

0
source

Source: https://habr.com/ru/post/1261330/


All Articles