This Python script is designed to check the status of your WiFi connection on a Windows system. If the WiFi network is inactive and not able to receive ping packets, the script will automatically turn off the WiFi, turn it on again, and check whether the connection is live again or not. The script utilizes the schedule
package for task scheduling, netsh
commands for controlling the WiFi interface, and the netifaces
package to retrieve meaningful network interface names.
- This script is specifically designed for Windows systems.
- The script requires administrative privileges to perform actions like turning off and on the WiFi interface.
Install the schedule
and netifaces
packages using the following commands:
pip install schedule pip install netifaces
- Run the script with administrative privileges to ensure it can control the WiFi interface.
- The script will schedule a periodic check of the WiFi connection status.
- If the WiFi connection is inactive (unable to receive ping packets), the script will automatically turn off and on the WiFi interface.
- The script will log the status of the WiFi connection in the console.
python wifi_checker.py
- Ensure that the script is run with administrative privileges to avoid permission issues.
- The script uses the
netsh
command to control the WiFi interface. If there are any issues with the execution ofnetsh
, the script may not work as expected.
- Schedule Package Documentation
- Stack Overflow: How do I get a cron-like scheduler in Python?
- Stack Overflow: Turn WiFi off using Python on Windows 10
- Stack Overflow: How to get meaningful network interface names instead of GUIDs with netifaces?
- Stack Overflow: Request UAC elevation from within a Python script