Writing a script/batch file/whatever to change my IP settings?

vj8usa

Senior member
Dec 19, 2005
975
0
0
When I game with my friends and we're using laptops, we use an ad-hoc network to reduce latency. The annoying thing about this is that we have to switch our IPv4 settings to use a specific IP, but I have to switch this back to obtaining an automatic IP every time I want to go back onto the internet. Is there a way to script this so I could click on a shortcut to use a fixed IP, and another shortcut to go back to automatic? Maybe even something that switches the network I'm connected to at the same time.
 

RebateMonger

Elite Member
Dec 24, 2005
11,586
0
0
You can use Windows networking "Alternate Configuration" setting.

If Windows is set to "Receive an IP address automatically" AND if it doesn't find a DHCP server when booting, it'll check for an "Alternate IP Address" setting and use that. Next time you boot, if it finds a DHCP Server, it'll use that information. If it doesn't find a DHCP Server, it'll use the Alternate Address settings.

http://technet.microsoft.com/en-us/library/cc779231(WS.10).aspx
 

Pantlegz

Diamond Member
Jun 6, 2007
4,627
4
81
netsh interface ip set address name="Local Area Connection" static 192.168.0.100 255.255.255.0 192.168.0.1 1
will set the IP to whatever you put in and
netsh interface ip set address="Local Area Connection" dhcp
will change it back to DHCP. make the appropate changes and make them batch files...

you'd also need to set the default gateway if you want to get out the the Ad Hoc network. And obvisously you'd change the name of the connection if you want your wireless connection to have the changes applied.

For more option just type netsh interface ip <enter> then set address <enter> and it will give you the help/syntax for the commands you're looking for.
 
Last edited: