Welcome Guest ( Log In | Register )



2 Pages V   1 2 >  
Reply to this topicStart new topic
> Switch Network Settings With Batch Files, A quick way to change IP, Gateway, DNS
curare
post Nov 10 2005, 12:55 PM
Post #1


Member [ Level 2 ]
Group Icon

Group: Members
Posts: 60
Joined: 3-November 05
From: Austria/Thailand
Member No.: 9,419



Let's suppose you are using two network settings with your laptop frequently. Wether it's a wireless or wired network, all the same: Every time you want to change the IP, subnet mask, default gateway and DNS Server(s) of your network connection in any flavour of Windows, you have to click through menus, submenus, and from that you go to yet another submenu... you have been there, it's awful. mad.gif

There is a better way: the command "netsh" on your command prompt can change all the aforementioned settings, and if you put them in a batch file, you can change them with a double mouse click.

To familiarize yourself with the command, click on "Start/Run" and enter "cmd". The command prompt opens. Enter "netsh /?" and you'll see the options and parameters of this powerful command and its subsets.

Open your network connections folder in the Control Panel. Windows usually calls the Network Interface Card "Local Area Connection" If you want to change the settings of your wireless network settings go to the appropriate status window. Make sure you know the name. Click on it, than click "Properties" and there double-click "Internet Protocol (TCP/IP)" This is where you usually go when you change those settings.

Now open your text editor and create a new file which you will call "Connection_settings_1.bat", or whatever is easily memorable and you associate with your settings # 1. Enter the following code:

CODE

netsh interface ip set address name="Local Area Connection" source=static addr=111.222.333.444 mask=255.255.255.255
netsh interface ip set address name="Local Area Connection" gateway=555.666.777.888 gwmetric=0
netsh interface ip set dns name="Local Area Connection" source=static addr=999.111.222.333  
netsh interface ip add dns name = "Local Area Connection" addr = 444.555.666.777  


Of course you must enter the numbers if the IP, subnet mask, gateway and DNS Server(s) according to your settings! As most of you know, 111.222.333.444 is just an example of an actually non-existing IP address. Save the file.

Assuming that your connection settings #2 are different, say with DHCP, than create another batch file and name it differently from the first.

CODE

netsh interface ip set address name="Local Area Connection" dhcp
netsh interface ip set dns name="Local Area Connection" dhcp


Save the file. If you need WINS you should enter the code

CODE

netsh interface ip set wins name="Local Area Connection" source=static addr=   .   .   .  


at the end of the batch files(s) with the correct settings instead of the dots.

Now test your new batch files. When you double-click on one, a command prompt window opens and the batch file is processed line by line. This takes some time (25 seconds in my case with a 2.8 GH Intel Processor), it is not done instantly. When the processes are finished the window closes.

To check if the settings are applied correctly, open a command prompt and entee "ipconfig". Than double-click on the second batch file and after it is finished put the command prompt where you entered "ipconfig" in focus and enter "ipconfig" again. The settings have changed with one double-click! rolleyes.gif

A final note: Yes, there is little proggies which do this job as well. One of them is even free. But you can do it without launching any extra program, using the built - in capabilities of your operating system.

curare
Go to the top of the page
 
+Quote Post
OpaQue
post Nov 12 2005, 07:41 PM
Post #2


Administrator
Group Icon

Group: Admin
Posts: 467
Joined: 26-August 04
Member No.: 1
myCENTs:85.82



Nice professionally written tutorial. Keep it up smile.gif
Go to the top of the page
 
+Quote Post
miCRoSCoPiC^eaRt...
post Nov 13 2005, 03:20 AM
Post #3


PsYcheDeLiC dR3aMeR
Group Icon

Group: Admin
Posts: 2,242
Joined: 29-January 05
From: Nakorn Chaisri, Thailand
Member No.: 2,411
myCENTs:84.36



Yeah hey -where's the reputation system ... we need one back for sure wink.gif Otherwise such works go completely unappreciated. Good one curare - that's the kind of well organized and quality tutorial/post we're always hoping for smile.gif
Go to the top of the page
 
+Quote Post
curare
post Nov 13 2005, 10:40 AM
Post #4


Member [ Level 2 ]
Group Icon

Group: Members
Posts: 60
Joined: 3-November 05
From: Austria/Thailand
Member No.: 9,419



Thank you for your kind words, gentlemen. I have worked some hours on this... and I enjoyed it!

I have a minor (?) request: could you please show your appreciation for this howto by adding some points to my account? While my hosting request has been kindly approved by our dear leader tongue.gif I am stuck at 31,25 points and my guess would be that this howto should be worth another two or three points smile.gif

TIA,

curare
Go to the top of the page
 
+Quote Post
MarkBla
post Dec 18 2005, 01:31 PM
Post #5


Member [ Level 1 ]
Group Icon

Group: Members
Posts: 45
Joined: 12-December 05
From: IJsselstein Netherlands
Member No.: 10,088



Heey, cool.gif

You can also set DHCP Server on. Everytime you connect, you will receive a new ip adres. tongue.gif

The only disadvantages are that your ip adres may change every time you reconnect. But that's only in some cases a problem. dry.gif


Greets,
Mark
Go to the top of the page
 
+Quote Post
iGuest
post Sep 26 2007, 07:52 AM
Post #6


Newbie [ Level 1 ]
Group Icon

Group: Members
Posts: 0
Joined: 1-November 07
Member No.: 25,869



You can also try "Net Profile Switch" http://www.jitbit.com/netprofileswitch.aspx to store and switch multiple network profiles
Go to the top of the page
 
+Quote Post
iGuest
post Jan 14 2008, 03:17 AM
Post #7


Newbie [ Level 1 ]
Group Icon

Group: Members
Posts: 0
Joined: 1-November 07
Member No.: 25,869



Hi

Do you know a way to run multiple batch files with netsh, at certain intervals of time. I want to schedule ip changing at 10 minutes interval, let's say.
Can it be done?
Greets!

-kukubau
Go to the top of the page
 
+Quote Post
iGuest
post Mar 12 2008, 06:46 PM
Post #8


Newbie [ Level 1 ]
Group Icon

Group: Members
Posts: 0
Joined: 1-November 07
Member No.: 25,869



schedule network settings batch
Switch Network Settings With Batch Files

Replying to Feedbacker

Sure, there's already a tool. "scheduled tasks". Then schedule the task to run the batch file at whatever interval you want.

-reply by John Smith
Go to the top of the page
 
+Quote Post
iGuest
post Apr 11 2008, 08:49 AM
Post #9


Newbie [ Level 1 ]
Group Icon

Group: Members
Posts: 0
Joined: 1-November 07
Member No.: 25,869



this doesnt work
Switch Network Settings With Batch Files

I have copied and pasted the exact text in the web page above into a bat file and run it, but it just doesnt seem to work, I am trying to update my wireless connection settings in vista (so I change the name to Wireless network connection etc) but still nothing, please help! :(

Thanks

Pete

-reply by pete
Go to the top of the page
 
+Quote Post
iGuest
post Apr 22 2008, 04:53 AM
Post #10


Newbie [ Level 1 ]
Group Icon

Group: Members
Posts: 0
Joined: 1-November 07
Member No.: 25,869



Very useful info
Switch Network Settings With Batch Files

This tutorial saved my day. I used this technique to switch between two networks. It works just fine. Very informational and useful. Keep it up!

-reply by Subbu
Go to the top of the page
 
+Quote Post

2 Pages V   1 2 >
Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics


 



- Lo-Fi Version Time is now: 22nd November 2008 - 09:15 AM