from subprocess import check_output
output = check_output('netsh wlan connect _Wifi_name_', shell=True)
print output
The rest is up to you.
Consider merging in the following (you gotta do some work yourself man..):
with open('mypasswords.txt') as fh:
for line in fh:
...
Pragmatically "writing" passwords as input via python instead of passing it as a parameter:
from subprocess import Popen, STDOUT, PIPE
from time import sleep
handle = Popen('netsh wlan connect _Wifi_name_', shell=True, stdout=PIPE, stderr=STDOUT, stdin=PIPE)
sleep(5) # wait for the password prompt to occur (if there is one, i'm on Linux and sudo will always ask me for a password so i'm just assuming windows isn't retarded).
handle.stdint.write('mySecretP@ssW0rd\n')
while handle.poll() == None:
print handle.stdout.readline().strip()
A more controlled version of it.