One click switch network settings

December 16th, 2011

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.

One-click switch between network settings for different locations (Windows)

July 20th, 2009

Wizard Update: One click switch network settings for windows 7

Mobile computers are everywhere now. Many people need to connect to networks (wired or wireless) in more than one place – at home and at work. One of the annoyances of current Windows interface is that you cannot easily store connection profiles – the way you can in MacOS X (called “Locations”) for quite a long time.

There is a workaround for that, involving a simple preliminary network setup + creation of a shortcut. I will briefly describe it here in 3 steps (you will have to repeat for each connection profile you would like to create). Here is how it goes:

[preparation]
Open a command prompt
(click STARTRun… then type cmd and click OK),
type md %windir%\netsettings (or copy it from here and paste it in the command prompt with a right-click) and hit Enter. Don’t close the command prompt yet.

  1. Make all network settings for the current profile (e.g. Office) – go to Network Connections, select the appropriate connection (wired and/or wireless) and set IP-address, network mask, default gateway, DNS servers, etc.
  2. Execute in the command prompt the following command
    netsh -c interface dump > %windir%\netsettings\office.txt
    and hit Enter.
  3. Create a shortcut on your desktop by minimizing all open windows, right-clicking on an empty place on the desktop and selecting New -> Shortcut…
    In the new window that opens, type (or better paste) the following
    netsh -f %windir%\netsettings\office.txt
    and click Next…
    Type a name for the profile (for instance Office settings) and click Finish.

Repeat steps 1-3 for as many profiles you need to create, changing office.txt with home.txt (etc.) in steps 2 and 3. Give each profile shortcut a distinguishable name.

You can now switch between different network profiles by simply clicking the appropriate icon on the desktop!

Note that this approach creates a full network profile (including settings for all network interfaces – wired and wireless), so in rare situations you might need to create different combinations of settings. It is also useful to have a setting with all connections set to auto, in case you need to access networks in hotels, airports and other public places.


Technology Digital Day - your source of daily digital experience. Technology blogs Technology Blog Directory