The last tip One-click switch between network settings for different locations (Windows) has gained a lot of attention from people searching to make their lives easier. Through testing in Windows 7, I found it not so convenient. I now present a simpler, more robust solution for Windows 7.
(0) I strongly suggest you rename your existing connections to something shorter and simpler. Microsoft have introduced naming of the type ‘Local Area Connection’, ‘Wireless Network Connection’ etc. While there certainly is reason behind that decision, for a home/office computer I personally find LAN and WIFI better. Go to Start button and type View network connections in the search field. Click on View network connections contol panel widget. Then rename ‘Local Area Connection’ to LAN and ‘Wireless Network Connection’ to WIFI.
(1) Open Notepad and copy the following 3 lines. Each line should start with the command netsh:
netsh interface ip set address LAN static <ipaddress> <subnetmask> <gateway> <metric>
netsh interface ip set dns LAN static <dnsaddress1>
netsh interface ip add dns LAN static <dnsaddress2>
On the blog the <gateway> and <metric> are on a second line, but they belong to the first.
Substitute <ipaddress>, <subnetmask>, <gateway>, <metric>, <dnsaddress1> and <dnsaddress2> with the values, provided by your ISP or corporate network administrator. Metric can be substituted with 1.
netsh interface ip set address LAN static 192.168.0.100 255.255.255.0 192.168.0.1 1
netsh interface ip set dns LAN static 192.168.0.1
netsh interface ip add dns LAN static 192.168.0.2
(2) Save the file as something descriptive for the location, e.g. home.bat, office.bat or university.bat, giving it a .bat extension, instead of the default .txt. Make sure Save as type: is set to All files (*.*), otherwise Notepad will append a .txt extension automatically.
(3) Now open a new Notepad window and paste the following lines to have the settings automatically acquired by the network:
netsh interface ip set address LAN dhcp
netsh interface ip set dns LAN dhcp
(4) Save as auto.bat, again observing the Save as type: All files (*.*).
(5) Keep all the files together at a convenient place (e.g. a folder on your Desktop or elsewhere).
(6) Activate the appropriate settings by right-clicking the corresponding file and selecting Run as Administrator from the context menu.
Same approach can be used for creating WiFi presets, substituting the word LAN from the commands with WIFI.
Note: In the commands above, LAN is the name of the network connection. If you have not changed it, substitute with the default ‘Local Areas Connection’ or any other name you have chosen. If the name contains spaces, make sure it is surrounded with quotes, otherwise they can be omitted.