DOS batch file script to change IP address on Win7

Here is a simple DOS batch file to change system IP addres in a second.

 

1. Create a batch file on DOS prompt.

– Make sure extension of the file is not *.txt, but *.bat

 

2. Copy and paste below script

 

* Change IP address that you want to be changed.

 

@echo off
echo Choose:
echo [A] Set DHCP
echo [B] Set Static IP=(192.168.77.234)
echo [C] Set Static IP=(192.168.88.234)

echo.
:choice
SET /P C=[A,B,C]?
for %%? in (A) do if /I "%C%"=="%%?" goto A
for %%? in (B) do if /I "%C%"=="%%?" goto B
for %%? in (C) do if /I "%C%"=="%%?" goto C
goto choice

:A
@echo off
echo Resetting IP Address and Subnet Mask For DHCP
netsh int ip set address name = "Local Area Connection" source = dhcp
ipconfig /renew
echo Here are the new settings for %computername%:
netsh int ip show config

pause
goto end

:B
@echo off
echo "Set static IP : 172.168.77.234"
netsh int ip set address name = "Local Area Connection" source = static addr = 192.168.77.234 mask = 255.255.255.0 gateway = 192.168.77.1
netsh int ip show config
pause
goto end

:C
@echo off
echo "Set static IP : 172.168.88.234"
netsh int ip set address name = "Local Area Connection" source = static addr = 192.168.88.234 mask = 255.255.255.0 gateway = 192.168.88.1
netsh int ip show config
pause
goto end

:end

 

* Option A will bring a bit latency, but it is normal to get IP address.

 

 

Leave a Reply