Advertisement
steve-shambles-2109

Switch WiFi on or off.

Apr 3rd, 2020
839
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.64 KB | None | 0 0
  1. """"Code snippets vol-48-snippet-239
  2.    Switch WiFi on or off.
  3.  
  4. Download all snippets so far:
  5. https://wp.me/Pa5TU8-1yg
  6.  
  7. Blog: stevepython.wordpress.com
  8.  
  9. Requirements: None.
  10.  
  11. origin:
  12. https://www.tutorialexample.com/best-practice-to-python-enable-and-disable-wifi-connection-on-win-10-python-tutorial/
  13. """
  14.  
  15. import os
  16.  
  17. WIFI_NAME = 'Local Area Connection' # You may need to change this to your connection name.
  18. ENABLE_WIFI = 'netsh interface set interface "'+WIFI_NAME+'" enabled'
  19. DISABLE_WIFI = 'netsh interface set interface "'+WIFI_NAME+'" disabled'
  20.  
  21. #disable wifi, if network is OFFLINE
  22. #os.popen(DISABLE_WIFI)
  23. os.popen(ENABLE_WIFI)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement