From 1000ca7451378aad24459def6fc45579e2c1469c Mon Sep 17 00:00:00 2001 From: cyberspunk Date: Thu, 1 Oct 2020 13:06:33 +0530 Subject: [PATCH] Add files via upload --- Auto_wificonnect.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 Auto_wificonnect.py diff --git a/Auto_wificonnect.py b/Auto_wificonnect.py new file mode 100644 index 0000000..1ed8cab --- /dev/null +++ b/Auto_wificonnect.py @@ -0,0 +1,29 @@ +import os +import sys +# it will show the saved networks +saved_profiles= os.popen(" netsh wlan show profiles").read() +print(saved_profiles) + +#it will show the available networks +available_profiles= os.popen('netsh wlan show networks').read() +print(available_profiles) + +# to take wifi name which wants to connect +prefered_ssid= input('enter the wifi name to connect with!!') + +# it will disconnect from the current network +response= os.popen('netsh wlan disconnect').read() +print(response) + +# it checks for the wifi that is saved or not +if prefered_ssid not in saved_profiles: + print('Profile for ' + prefered_ssid + 'not saved in the system' ) + print('Can not connect to the network!! ') + sys.exit() + +# it checks the wifi is available or not +elif prefered_ssid in available_profiles: + print('Connecting to !!! '+ prefered_ssid) + os.popen('netsh wlan connect name=' +'"'+prefered_ssid+'"') #this command helps to connect with the given wifi + print('Connected to '+prefered_ssid) + \ No newline at end of file