When you work on a device which has network connectivity, you might need to change IP address of a network adaptor on your laptop quite often. The usual way to change IP address is using the following dialog.

Fig1_Internet_Protocol_Version_4_Properties_Dialog Fig1_Internet_Protocol_Version_4_Properties_Dialog

Nothing new. But there is one thing. If you use this way, windows requires you to restart your PC. Only after restarting Windows, new network configuration will be applied. That was really annoying for me. I just wanted to change IP address with just one click, needless to say without rebooting.

Batch file solution

Here is the batch file I use for this purpose.

netsh interface ip set address name="Local Area Connection" static 192.168.10.10 255.255.255.0
TIMEOUT /T 5 /NOBREAK
ipconfig
ping 192.168.10.12 -t

This batch configures “Local Area Connection” network with - IP address = 192.168.10.10 - Subnet mask = 255.255.255.0

If you want to use DHCP, you can simply change the property of netsh command to

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

In my environment, it takes a few seconds the new network configuration to be applied. This is why I added 5 seconds pause using TIMEOUT command. The time might be vary depends on your environment. Please make sure that you need to identify your network adaptor by its name in name property of netsh command.

This tiny batch file saves my time every day.

References/External links

Netsh commands for Interface Internet Protocol version 4 (IPv4)
Microsoft TechNet Command-Line Reference - Timeout