An interactive script to change your IP Addr, SM, DG and back to DHCP using netsh

Any time you are doing a lot of testing and need to change your ip addr in Windows to several different subnets typing the netsh command over and over again or going to "open network and sharing center" and changing your adapter settings gets old really fast.

Save each script as a .bat file and then put them in a directory that is in your system variable path so that it can run from cmd or powershell.


IP.bat

@echo off
set /p "ipaddr=Enter IP address:"
set /p "netmask=Enter subnet mask:"
set /p gateway="Enter default gateway:"
netsh interface ipv4 set address "Local Area Connection" static %ipaddr% %netmask% %gateway% 1


DHCP.bat

@echo off
set /p "dhcp=Hit Enter to set Local Area Connection to DHCP:" netsh interface ipv4 set address "Local Area Connection" dhcp %dhcp%

Comments

Unknown said…
Good stuff Lee, thanks - Josh