Skip to content
This repository has been archived by the owner on Jan 22, 2022. It is now read-only.

Windows support #2

Open
techtonik opened this issue Jan 11, 2015 · 12 comments
Open

Windows support #2

techtonik opened this issue Jan 11, 2015 · 12 comments

Comments

@techtonik
Copy link

Awesome idea. It kicked me to search how to do that in Windows - http://www.hanselman.com/blog/HowToConnectToAWirelessWIFINetworkFromTheCommandLineInWindows7.aspx

@joshvillbrandt
Copy link
Owner

Nice! Thanks for the link.

I don't have any immediate need for this myself, but I'll happily consider a pull request if you'd like to submit one.

Copying the meat of that post here for posterity:

netsh wlan connect ssid=YOURSSID name=PROFILENAME

# What's a profile? It's the only thing required. You can see them with:

C:\>netsh wlan show profile

# Profiles on interface Wireless Network Connection: 
# ...snip.. 
# User profiles 
# ------------- 
#     All User Profile     : Clear Spot b0e 
#     All User Profile     : HANSELMAN-N 
#     All User Profile     : Quiznos

# These are the same ones that you see in the wireless networks dialog...

# Manage Wireless Networks 

# You can set these up and refer to them by name from the command line, or a batch file, etc. Nice to do for the places you are regularly.

# If you have multiple wireless cards (What's wrong with you!?) then you have to be more specific:

netsh wlan connect ssid=YOURSSID name=PROFILENAME interface="WIRELESS NETWORK CONNECTION"

# And of course, you can
netsh wlan disconnect

# And include the interface optionally, for multiple interfaces. Additionally, interesting things can be seen with

netsh wlan dump

# This is nice because you can

netsh wlan dump > myconfig.txt

on one machine and then later on another machine

netsh exec myconfig.txt

@techtonik
Copy link
Author

I am not sure how to handle the "Profiles" stuff. What should be the logic behind wireless.connect(ssid='ssid', password='password')?

  1. How to create profile to connect to if it doesn't exist?
  2. How to find one for the given SSID?
  3. How to select correct profile if there are multiple ones for the given SSID?

@joshvillbrandt
Copy link
Owner

Looks like you figured out 2 and 3 in the pull request. The answer to 1 (and 2 and 3) are driver specific. (It looks like the program/driver that you are interfacing with here is netsh.) Since I don't have experience with netsh, I'm not sure how to create new profiles, but it would definitely be a nice feature to have. All of the existing drivers in this package support connecting to previously unconfigured wireless connections.

@techtonik
Copy link
Author

During work on 6b59fc4 I found that Windows seems to support multiple SSID per profile. It may be worthy to create some PythonWireless profile. It may to connect faster, because querying all profiles for their SSID is slow. I still don't know how to connect to some unknown SSID from command line and set password.

@techtonik
Copy link
Author

Found a faster strategy to query available profiles - read files from C:\ProgramData\Microsoft\Wlansvc\Profiles\Interfaces

Windows has no way to decrypt WiFi password under user account - needs to do this from LocalSystem. I see the way to create new profile with netsh wlan add profile, but no way so far to connect to SSID with explicitly mentioned password.

@techtonik
Copy link
Author

I see no way to configure SSID for existing profile on Vista. =/

@techtonik
Copy link
Author

One netsh wlan add profile can be used to load .XML files, but it need password to be encrypted somehow.

@techtonik
Copy link
Author

Ok, it might be possible to create XML profile with encrypted password https://stackoverflow.com/questions/2374331/python-win32crypt-cryptprotectdata-difference-between-2-5-and-3-1 and add it if it doesn't exist of if password is different. Need to check if encryption is valid.

@techtonik
Copy link
Author

Looks like this trick with <protected>false</protected> might work. Needs testing though. https://superuser.com/questions/133097/netsh-wlan-add-profile-not-importing-encrypted-passphrase

@joshvillbrandt
Copy link
Owner

Nice! Looks like you have all of the pieces to get this to work. This will be similar to my existing "wpa_supplicant" adapter in that a temporary file needs to be created in order to establish the profile.

What versions of Windows are you testing on? I would say Windows 7 and up would be good to support. I wouldn't worry about Vista.

@techtonik
Copy link
Author

Vista is my only, and most likely the last Windows. =)

@techtonik
Copy link
Author

As I promised, Vista was my last Windows, so don't expect me to get back to it. )

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants