Saturday, 30 June 2012

Change Ip address with batch file

My boss having Laptop & he having different IP address at office & 

home, & every day when he comes to office he need to change his 

laptop IP adress everyday. So i written a batch script to change IP 

address with single click, & i know this problem is with many people 

so i am sharing this batch script with you...

OK let's starting creating batch file

Copy the code below :

@echo off 
echo Choose: 
echo [A] Set Static IP.  
echo [B] Set Obtain adress automatically.
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 

echo "Setting Static Ip" 
netsh interface ip set address "Local Area Connection" static %D_Gate%
netsh int ip set dns "Local Area Connection" static
netsh int ip add dns "Local Area Connection" 
netsh int ip show config 
goto end

ECHO Resetting IP Address and Subnet Mask For DHCP 
netsh int ip set address name = "Local Area Connection" source = dhcp
netsh int ip set dns name = "Local Area Connection" source = dhcp
ipconfig /renew

ECHO Here are the new settings for %computername%: 
netsh int ip show config

goto end 
echo Visit

Now paste the code into Notepad & save it as IP changer.bat

Very Important instruction :-

in this batch script i had defined my ip address ,DNS ,Default 

gateway & Subnet mask.

but you need to replace as per your network settings....

What to change ?   is my IP address  is my Subnet mask  is my Default gateway is my Primary DNS  is my Secondary DNS

Replace all above addresses with your network addresses & save the 


That's it...

Work Smarter...


  1. mast re.....keep giving such tips....!!!good to learn from you...