Skip to content

Instantly share code, notes, and snippets.

@saurabhwahile
Created December 16, 2015 06:02
Show Gist options
  • Save saurabhwahile/ea4d2933f988dc8e7b1d to your computer and use it in GitHub Desktop.
Save saurabhwahile/ea4d2933f988dc8e7b1d to your computer and use it in GitHub Desktop.
Switch gateway, Ex: for failover/redundancy
@echo off
for /f "tokens=2,3 delims={,}" %%a in ('"WMIC NICConfig where IPEnabled="True" get DefaultIPGateway /value | find "I" "') do set gateway=%%~a
IF %gateway%==192.168.1.1 (
netsh interface ip set address name="Wi-Fi" static 192.168.1.10 255.255.255.0 192.168.1.41 1
) ELSE (
netsh interface ip set address name="Wi-Fi" static 192.168.1.10 255.255.255.0 192.168.1.1 1
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment