Skip to content

Instantly share code, notes, and snippets.

@rendfall
Created July 18, 2014 12:03
Show Gist options
  • Save rendfall/9a7dd6f01c570fe79fd6 to your computer and use it in GitHub Desktop.
Save rendfall/9a7dd6f01c570fe79fd6 to your computer and use it in GitHub Desktop.
IP Switcher for Windows
:: --------------------------
:: --------SETTINGS----------
:: --------------------------
@set connectionname=Wi-Fi 2
:: --------------------------
:: ---------SELECT-----------
:: --------------------------
@echo off
echo Choose wisely:
echo.
echo [1] Profile: myNetwork 192.168.3.57
echo [2] Set DHCP
echo [3] Set Static
echo.
echo [X] EXIT
echo.
echo.
:: --------------------------
:: ----------CHOICE----------
:: --------------------------
:choice
choice /c 123X /n /m ">>"
if errorlevel 4 goto end
if errorlevel 3 goto C
if errorlevel 2 goto B
if errorlevel 1 goto A
goto choice
:: --------------------------
:: ----------OKINET----------
:: --------------------------
:A
@echo off
set IP_Addr=192.168.3.57
set D_Gate=192.168.3.1
set Sub_Mask=255.255.255.0
set DNS_primary=192.168.3.3
netsh interface ip set address "%connectionname%" static %IP_Addr% %Sub_Mask% %D_Gate% 1
netsh interface ipv4 set dns "%connectionname%" static %DNS_primary%
echo interface ip set address "%connectionname%" static %IP_Addr% %Sub_Mask% %D_Gate%
pause
goto end
:: --------------------------
:: -----------DHCP-----------
:: --------------------------
:B
@ECHO OFF
ECHO Resetting IP Address and Subnet Mask For DHCP
netsh int ip set address name="%connectionname%" source=dhcp
netsh interface ipv4 set dns "%connectionname%" dhcp
pause
goto end
:: --------------------------
:: ----------STATIC-----------
:: --------------------------
:C
@echo off
echo "Please enter Static IP Address Information"
echo "Static IP Address:"
set /p IP_Addr=
echo "Default Gateway:"
set /p D_Gate=
echo "Subnet Mask:"
set /p Sub_Mask=
echo "DNS primary":
set /p DNS_primary=
echo "Setting Static IP Information"
netsh interface ip set address "%connectionname%" static %IP_Addr% %Sub_Mask% %D_Gate% 1
netsh interface ipv4 set dns "%connectionname%" static %DNS_primary%
netsh int ip show config
pause
goto end
:: --------------------------
:end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment