Skip to content

Instantly share code, notes, and snippets.

@utarn
Last active May 17, 2018 01:05
Show Gist options
  • Save utarn/f32ac3e5ed84b051198b975eea1e14dd to your computer and use it in GitHub Desktop.
Save utarn/f32ac3e5ed84b051198b975eea1e14dd to your computer and use it in GitHub Desktop.
Windows Batch Script for Switching between two SSID if one is failed (Change Leelawadee-Secure and TP-Link_OOH)
@echo off
set ipcheck="google.com"
set wifi1="Leelawadee-Secure"
set wifi2="TP-Link_OOH"
echo Check Internet Connection
ping -n 1 %ipcheck% | find "TTL" > nul
if %errorlevel% == 0 goto finish
echo Checking Leelawadee-Secure
netsh wlan connect name=%wifi1%
timeout 10 > nul
ping -n 1 %ipcheck% | find "TTL"
if %errorlevel% == 1 (
echo %date% %time% %wifi1% is Connected >> failover.log
echo %wifi1% is failed
echo Checking %wifi2%
netsh wlan connect name="TP-Link_OOH"
timeout 10 > nul
ping -n 1 %ipcheck% | find "TTL"
if errorlevel 1 (
echo Not connected!
) else (
echo %date% %time% %wifi2% Connected >> failover.log
echo %wifi2% connected!
)
) ELSE (
echo %date% %time% %wifi1% Connected >> failover.log
echo %wifi1% Connected!
)
:finish
echo %date% %time% Internet is connected. Remain no change to SSID. >> failover.log
echo Internet is connected. Remain no change to SSID.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment