Batch file for Changing IPs from Static to DHCP

Following is the content of the batch file. Just copy the below script in notepad and save as .bat file.  First change the static IPs as per your need. This script is very useful for offices where two internet connection are working and one is having static ip address and other DHCP

@echo off
echo Choose Option to set IP Address:
echo [A] Reliance
echo [B] Connect

echo.

:choice
SET /P C=[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 “Setting Static IP Information”

netsh interface ipv4 set address name=”Local Area Connection 2″ source=static address=115.252.148.36 mask=255.255.255.240 gateway=115.252.148.33
netsh interface ipv4 set dns name=”Local Area Connection 2″ source=static address=124.124.5.135 register=NONE
netsh interface ipv4 add dns name=”Local Area Connection 2″ address=124.124.5.136 index=2
netsh interface ipv4 set wins name=”Local Area Connection 2″ source=static address=none
netsh interface ip show config

goto end

:B

@ECHO OFF
ECHO Resetting IP Address and Subnet Mask For DHCP
netsh interface ipv4 set address name = “Local Area Connection 2″ source = dhcp
netsh interface ipv4 set dns name=”Local Area Connection 2” source = dhcp
ECHO Here are the new settings for %computername%:
netsh interface ip show config

goto end

:end

Submit a Comment

Your email address will not be published. Required fields are marked *