title: Change a wifi profile's password through XML file and netsh wlan (or Python)
body: <p>I try the joys of netsh wlan under win.10. So basically:</p>
  <ol>
  <li>I have an XML file called virgin.xml, which is, as you can, guess &quot;virgin&quot;. The file:</li>
  </ol>
  <pre><code>&lt;?xml version='1.0' encoding='utf-8'?&gt;
  &lt;WLANProfile xmlns=&quot;http://www.microsoft.com/networking/WLAN/profile/v1&quot; 
                   xmlns:ns1=&quot;http://www.microsoft.com/networking/WLAN/profile/v3&quot;&gt;
      &lt;name&gt;HERE THE NAME IS EMPTY, THIS IS WHY THE FILE IS CALLED &quot;VIRGIN&quot;&lt;/name&gt;
      &lt;SSIDConfig&gt;
          &lt;SSID&gt;
              &lt;name&gt;ALSO HERE&lt;/name&gt;
          &lt;/SSID&gt;
      &lt;/SSIDConfig&gt;
      &lt;connectionType&gt;ESS&lt;/connectionType&gt;
      &lt;connectionMode&gt;auto&lt;/connectionMode&gt;
      &lt;MSM&gt;
          &lt;security&gt;
              &lt;authEncryption&gt;
                  &lt;authentication&gt;WPA2PSK&lt;/authentication&gt;
                  &lt;encryption&gt;AES&lt;/encryption&gt;
                  &lt;useOneX&gt;false&lt;/useOneX&gt;
              &lt;/authEncryption&gt;
              &lt;sharedKey&gt;
                  &lt;keyType&gt;passPhrase&lt;/keyType&gt;
                  &lt;protected&gt;false&lt;/protected&gt;
                  &lt;keyMaterial&gt;THE PASSWORD IS ALSO EMPTY&lt;/keyMaterial&gt;
              &lt;/sharedKey&gt;
          &lt;/security&gt;
      &lt;/MSM&gt;
      &lt;ns1:MacRandomization&gt;
          &lt;ns1:enableRandomization&gt;false&lt;/ns1:enableRandomization&gt;
      &lt;/ns1:MacRandomization&gt;
  &lt;/WLANProfile&gt;
  </code></pre>
  <p>And with a script I modify the file to enter the name of my wifi (antigon here) and the password. So now my &quot;virgin.xml&quot; isn't a virgin anymore, it's a classic wifi profile XML with a name and a password given inside.</p>
  <ol start="2">
  <li><p>I do <code>netsh wlan add profile filename = &quot;C:\virgin.xml&quot;</code> to add a profile from an XML file</p>
  </li>
  <li><p>I added a profile, however if I do <code>netsh wlan show profiles</code>, there is no &quot;virgin&quot; 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 <em>(maybe this is a point where I am wrong)</em></p>
  </li>
  <li><p>I do <code>netsh wlan connect</code> according to the syntax given on a site: <code>netsh wlan connect ssid = YOURSSID name = PROFILENAME</code> to connect into a wifi network giving the name and the profile (so that it gets the password). So for me: <code>netsh wlan connect ssid = antigon name = antigon</code></p>
  </li>
  <li><p>&quot;The connection request succeeded&quot;, it connects me.</p>
  </li>
  <li><p>I change the password in the XML file to put a false one and I repeat steps 2 to 4, &quot;The connection request was successful&quot;, and it still connects me ! <em>(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 ?)</em></p>
  </li>
  </ol>
  <p>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.</p>
  <p>*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!</p>