This Python script monitors the status of a Wi-Fi connection on a Windows system. When the network becomes inactive or fails to respond to ping requests, the script automatically disables and re-enables the Wi-Fi adapter, then verifies whether the connection has been successfully restored. It uses the schedule package for periodic execution, netsh commands to manage the Wi-Fi interface, and the netifaces package to obtain user-friendly 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 netifacesPip3 if using python3
- 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
netshcommand to control the WiFi interface. If there are any issues with the execution ofnetsh, the script may not work as expected.