Guide Changing Windows IP configuration with a batch file

Hi Guys,

I have access to three ISP's (at my three residences), and its a PITA to configure the network settings in Windows Vista every time I have to change to one of their (ISP's) networks.

So I created three batch files, with the requisite configurations which I execute with a simple double click whenever I need to change my network configuration.

Batch file #1 for ISP#1, batch file #2 to ISP #2 and so on.

*works for windows XP too.

U need the first two lines to erase any existing configuration (reset to defaults), if you are using a DHCP server you need only the first two lines.

In the configuration below, replace:

x.x.x.x -> Ip address

y.y.y.y -> Subnet Mask

The following are optional, erase them if you don't need them.

z.z.z.z -> IP address of the default gateway (optional)

a.a.a.a -> IP address of the Primary DNS server (optional)

b.b.b.b -> IP address of the alternate DNS server (optional)

(if you have opted for a personalized name) replace "local area connection" with the name of your adapter .

Copy the following to notepad, click save as, name the file as xyz.bat, where xyz is the name of your file. Select "All files" from the drop down menu "Save as type". Click save

netsh interface ip set address "Local Area Connection" dhcp

netsh interface ip set dns "Local Area Connection" dhcp

netsh interface ip set address name="Local Area Connection" static x.x.x.x y.y.y.y z.z.z.z 1

netsh int ip set dns "local area connection" static a.a.a.a

netsh int ip add dns "local area connection" b.b.b.b index=2

Just double click the batch file every time you need to change your network settings.

* on some PC's I have noticed that it takes about 20 odd seconds to complete, but it does nevertheless.

**please make sure you have your cable connected,the icon in Windows showing connected, else windows does not accept changes to the IP configuration.

Thank you,

abhi
 
awesome .. this is just what i needed .. thanks a lot mate .. i will try this .. repped \m/

and if i want to change just the ip, subnet and gateway, do i need to save the file as
netsh interface ip set address "Local Area Connection" dhcp
netsh interface ip set dns "Local Area Connection" dhcp
netsh interface ip set address name="Local Area Connection" static x.x.x.x y.y.y.y z.z.z.z 1

??????????
 
The below two lines to erase any existing configuration / pull configuration from a DHCP.

netsh interface ip set address "Local Area Connection" dhcp

netsh interface ip set dns "Local Area Connection" dhcp

The following two lines to set the configuration manually, where x.x.x.x -> Ip address and y.y.y.y -> Subnet Mask.

netsh interface ip set address name="Local Area Connection" static x.x.x.x y.y.y.y z.z.z.z 1
 
Back
Top