forked from alienbrains/ISB
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Project5: Automatic WiFi Connector bot
34 lines (24 loc) · 1.14 KB
/
Project5: Automatic WiFi Connector bot
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import os
import sys
saved_profiles = os.popen('netsh wlan show profiles').read() # To get the saved profiles
print(saved_profiles)
available_profiles = os.popen('netsh wlan show networks').read() # To get the available profiles
print(available_profiles)
preferred_ssid=input('Enter the preferred Wifi for your connection : ')
response = os.popen("netsh wlan disconnect").read()# To disconnect the present connection and connect to the preferred one
print(response)
if preferred_ssid not in saved_profiles:
print("Profile for "+preferred_ssid+" is not saved in system")
print("Sorry but can't establish the connection")
sys.exit()
else:
print("Profile for "+preferred_ssid+" is saved in system")
while True:
avail = os.popen('netsh wlan show networks').read() # To get the available profiles
#sleep(3)
if preferred_ssid in avail: # Checks if the preferred connection is available or not
print('Found')
break
print('--------Connecting----------')
resp = os.popen('netsh wlan connect name='+'"'+preferred_ssid+'"').read()
print(resp)