One click switch network settings

Wizard 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.

Example:

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.

Tags: , , , , ,

2 Responses to “One click switch network settings”

  1. Evan says:

    Outstanding, Thanks!

  2. I will first like to thank you for posting this. It really helped me get things straighten up with my network settings. I had to manually set my network settings every time I moved form home to office and back, but no more.

    Although your steps did not work correctly on my Windows 7 Pro, but they did provide me the path to go ahead with. Here are the steps I am using on my machine.

    ====Home (home.bat) ====
    netsh interface ipv4 set address name=”Local Area Connection” source=static address=192.168.1.4 mask=255.255.255.0 gateway=192.168.1.1
    netsh interface ipv4 set dnsservers name=”Local Area Connection” source=static 202.156.205.54 register=primary
    netsh interface ipv4 add dnsservers name=”Local Area Connection” 202.156.205.55
    netsh interface ipv4 set address name=”Wireless Network Connection” source=static address=192.168.1.3 mask=255.255.255.0 gateway=192.168.1.1
    netsh interface ipv4 set dnsservers name=”Wireless Network Connection” source=static 202.156.205.54 register=primary
    netsh interface ipv4 add dnsservers name=”Wireless Network Connection” 202.156.205.55

    ====Office (office.bat) ====
    netsh interface ipv4 set address name=”Local Area Connection” source=dhcp
    netsh interface ipv4 set dnsservers name=”Local Area Connection” source=dhcp
    netsh interface ipv4 set address name=”Wireless Network Connection” source=dhcp
    netsh interface ipv4 set dnsservers name=”Wireless Network Connection” source=dhcp

    Thanks again for help!