Switch IP address configurations between two networks using a simple batch program

I use an official Notebook which I often take home when dealing with official projects. The problem is I only have one Network Adaptor or LAN device on this machine. As a result, the network configurations in both locations becomes very tricky. As a network engineer, I know there are other possibilities of solving this problem but I just thought this little batch program might help someone else.

Just copy and past the content between “Start” and “End” on a file using notpad or other editing tools. Save and name the file what you want, run and follow the instructions. Enjoy and share! 😉

:::::::::::::::::::::::::::::::::: Start ::::::::::::::::::::::::::::::::::::::::

@echo off
cls
Echo ————————— Switch IP Address ——————————————————–
Echo (c) 2010 omotech computer services
Echo This Program was written on March 24, 2010 by Stanley O. Omoregie.
Echo It allow the easy switch of IP Address settings between two networks.
Echo The program is copyrighted and can only be used and distributed as it is,
Echo without removing this copyright information.
Echo —————————————————————————————————————–
echo Choose between A und B:
echo [A] Set Static IP Address (Office)
echo [B] Set DHCP (Home)
echo.
echo Choose between A und B:
echo [A] Set Static IP Address (Office)
echo [B] Set DHCP (Home)
:choice
SET /P C=
Echo.
Echo.[A,B]
for %%? in (A) do if /I “%C%”==”%%?” goto A
for %%? in (B) do if /I “%C%”==”%%?” goto B
goto choice
:A
@ECHO off
echo Please enter IP Adresse for choice [A]:
set /P IP_Addr=

echo Default Gateway:
set /P D_Gate=

echo Subnet Mask:
set /P Sub_Mask=

echo Setting static IP Address&
netsh interface ip set address “LAN” static %IP_Addr% %Sub_Mask% %D_Gate% 1
ECHO Here is the setting information for %computername%:
netsh int ip show config
pause
goto end

:B
@ECHO OFF
ECHO DHCP is resetting the IP Address and Subnet Mask.
netsh int ip set address name = “LAN” source = dhcp

ipconfig /renew

ECHO Here is the setting information for %computername%:
netsh int ip show config
pause
goto end

:end
Script END!

:::::::::::::::::::::::::::::::::: End ::::::::::::::::::::::::::::::::::::::::

I made an EXE file from the batch program. You can download this to get both files.


Posted in Networking and tagged , , by with comments disabled.