I try the joys of netsh wlan under win.10. So basically:
- I have an XML file called virgin.xml, which is, as you can, guess "virgin". The file:
 
<?xml version='1.0' encoding='utf-8'?>
<WLANProfile xmlns="http://www.microsoft.com/networking/WLAN/profile/v1" 
                 xmlns:ns1="http://www.microsoft.com/networking/WLAN/profile/v3">
    <name>HERE THE NAME IS EMPTY, THIS IS WHY THE FILE IS CALLED "VIRGIN"</name>
    <SSIDConfig>
        <SSID>
            <name>ALSO HERE</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>THE PASSWORD IS ALSO EMPTY</keyMaterial>
            </sharedKey>
        </security>
    </MSM>
    <ns1:MacRandomization>
        <ns1:enableRandomization>false</ns1:enableRandomization>
    </ns1:MacRandomization>
</WLANProfile>
And with a script I modify the file to enter the name of my wifi (antigon here) and the password. So now my "virgin.xml" isn't a virgin anymore, it's a classic wifi profile XML with a name and a password given inside.
I do
netsh wlan add profile filename = "C:\virgin.xml"to add a profile from an XML fileI added a profile, however if I do
netsh wlan show profiles, there is no "virgin" profile. I deduce that it created a profile with the name of the wifi indicated in the XML file, antigon. There was already one called antigon, the basic one because it is my wifi so I already connected into it, and when I look at the profiles, there is still only one antigon. Conclusion since I did not have an error message: it modified the information of the already existing antigon profile with those given in the XML file, among others the password (maybe this is a point where I am wrong)I do
netsh wlan connectaccording to the syntax given on a site:netsh wlan connect ssid = YOURSSID name = PROFILENAMEto connect into a wifi network giving the name and the profile (so that it gets the password). So for me:netsh wlan connect ssid = antigon name = antigon"The connection request succeeded", it connects me.
I change the password in the XML file to put a false one and I repeat steps 2 to 4, "The connection request was successful", and it still connects me ! (This is why I said that it could be a point where I am wrong at step 3 : maybe it didn't change the password and so it's pretty logic to still connect ?)
Does anyone know where the error is? It's annoying, I have all the elements in hand to do what I want but I can't manage to fit them correctly ! What I would like to do is when I put the right password in the XML file and run netsh wlan export and then netsh wlan connect, it connects me, and it does not work if I put the wrong password.
*What I can also do : I call batch files from a python script, which is my main script. So if you got a solution to connect to a wifi using Python, like, I know there are libraries like os that allow using cmd commands, I take them!