Script to Change IP Address

When using my personal computer at work, I have to change from DHCP to a static IP and it got really really frustrating to change my settings twice a day. So I got a script to do that for me and I think it will be very useful to some of you out there if I shared it.

Create a new text file and type the following in it:

netsh interface ip set address "Name-of-adapter (Commonly called Local Area Connection)" dhcp
netsh interface ip set dns "Name-of-adapter (Commonly called Local Area Connection)" dhcp

Save it but change the “.txt” extension to “.bat”. This sets your adapter to DHCP (automatic IP address, DNS, etc.) for home use.

For work use, create another text file and type the following into it:

netsh interface ip set address "Name-of-adapter (Commonly called Local Area Connection)" static 192.168.1.101 255.255.255.0 192.168.1.1
netsh interface ip set dns "Name-of-adapter (Commonly called Local Area Connection)" static 192.168.1.254
netsh interface ip add dns "Name-of-adapter (Commonly called Local Area Connection)" 192.168.1.255 index=2

Save it but change the “.txt” extension to “.bat”. This sets your adapter to static settings (static IP address, DNS, etc.) for work use.

Hopefully this will help you and reduce some of the frustration that comes with changing adapter settings when moving from home to work and back again.

Tags: , , ,