Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Moving my LapTop between work and home I need to change my internet proxy settings. Is there any build in way for windows 7 to change these settings based on my currently active network?

share|improve this question
1  
Owh I'd so like my laptop to do the same, just too lazy to look for the answer :-( –  Ivo Flipse Sep 24 '09 at 6:15
add comment

3 Answers 3

You could set this up with a PAC (Proxy Auto Configuration script). They're small scripts written in Javascript that let you specify various connection rules. Most modern desktop web browsers can read them with no problem, I have the same one set up in both Internet Explorer and Firefox.

A minimal PAC file that always sends you to the proxy server proxy.companyname on port 81:

function FindProxyForURL(url, host)
{
     return "PROXY proxy.companyname:8080";
}

And a slightly more complicated example of a PAC file that checks which network you're on by checking what IP address range you've picked up. In this example all client PCs in your company are given an IP address in the 10.10.* range by DHCP and access the internet via the proxy server proxy.companyname on port 81.

//Turn debug mode on by setting debug variable to any non-empty string
//Note that "" is an empty string, and that "0", "1" & "test" are not empty strings.


function FindProxyForURL(url, host)
  {
    var ip = myIpAddress();
    var debug = "";

    if(debug)
    {
        alert("proxy.pac IP=" + ip + "  HOST=" + host + "  URL=" + url);
    }

      // All client PCs on the internal network will have a 10.10.x.x address, check if I have this
     if (shExpMatch(ip, "10.10.*"))
     {
             if(debug)
          {
                 alert("Proxy for " + url);
             }
     return "PROXY proxy.companyname:81";
     }

     // If you have a different IP then this isn't the company network
     else 
     {
             if(debug)
          {
      alert("You are not at CompanyName so going direct for " + url);
             } 
            return "DIRECT";
     }

  }

The script also has a debug mode that you can use to test that it is working and which mode (PROXY or DIRECT connect) it thinks your current connection should be.

You could also make a more complex script that checks things like if the server you're connecting to is on your internal company network (and thus wants a DIRECT connection, even though your PC is currently on the company network) this is where you'd put anything you normally put in IE's proxy exceptions box, by expanding it like so:

//Turn debug mode on by setting debug variable to any non-empty string
//Note that "" is an empty string, and that "0", "1" & "test" are not empty strings.


function FindProxyForURL(url, host)
  {
    var ip = myIpAddress();
    var debug = "";

    if(debug)
    {
        alert("proxy.pac IP=" + ip + "  HOST=" + host + "  URL=" + url);
    }

    // Detect if trying to connect to internal/intranet host
    if(isPlainHostName(host) || dnsDomainIs(host, "intranet.companyname"))
    {
 if(debug)
 {
            alert("Direct for " + url);    
     }
    return "DIRECT";   
    }

    // Detect if trying to connect to URLs on the internal network via internal DNS suffix or IP address
    if(shExpMatch(url, "*.companyname") || shExpMatch(host, "10.100.*"))
    {
 if(debug)
 {
     alert("Direct for " + url);
 } 
        return "DIRECT";    
    } 

     // All client PCs on the internal network will have a 10.10.x.x address, check if I have this
     if (shExpMatch(ip, "10.10.*"))
     {
             if(debug)
          {
                 alert("Proxy for " + url);
             }
     return "PROXY proxy.companyname:8080";
     }

     // If you have a different IP then this isn't the company network
     else 
     {
             if(debug)
          {
      alert("You are not at CompanyName so going direct for " + url);
             } 
            return "DIRECT";
     }

  }

Use this file by saving it somewhere on your PC's C drive as something like proxy.pac, then for Internet Explorer, go to Tools -> Options (or Control Panel -> Internet Options) then click the Connections tab, click the LAN Settings button. Now take the tick out of the "Use a proxy server" box at the bottom, and instead put a tick in "Use automatic configuration script" and type in the address of your PAC file using a file:// URL like file://C:/proxy.pac.

IE proxy settings

Alternatively for Firefox go to Tools -> Options, click the Advanced tab, click the Network tab, click the Settings button, click the "Automatic proxy configuration URL" setting, again using a file:/// URL (note that in Firefox there are 3 slashes after the colon, eg file:///C:/proxy.pac.

Firefox proxy settings


Note that Internet Explorer 11 has changed this behaviour and you now can't load a PAC file from a 'file://' URL, you must use an 'HTTP://' or 'HTTPS://' URL.

In Internet Explorer 11, the WinINET team has disabled WinINET’s support for file:// based scripts to promote interoperability across network stacks. Corporations are advised to instead host their proxy configuration scripts on a HTTP or HTTPS server.

There is a work-around that can re-enable this feature for the moment, but you are not advised to use it, as future updates could disable this too.

As a temporary workaround, this block can be removed by setting the following registry key:

Key:   HKLM\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\Internet Settings\
Value: EnableLegacyAutoProxyFeatures
Type:  REG_DWORD
Data:  1

Keep in mind that this should only be a temporary measure, as this block was introduced for good reasons, and removing the block won’t magically fix your WinHTTP-based applications.

Note also that after making this change IE11 you will need to change the address setting for your auto-config script as IE 11 only accepts one syntax for this (see the bottom of the linked article on the IE Internals blog below).

However, as noted, it is unlikely that this registry key workaround will continue to work in future versions of Internet Explorer, so you are much better off finding a way to hold the PAC on a web server. The Windows built-in IIS web server would do, and there are more minimal ones out there that would work for installing on your laptop too.

More info on the IE Internals blog entry Understanding Web Proxy Configuration.

share|improve this answer
    
That's pretty cool until you get onto another public wireless network using the same private IP range as I happen to use at my house. :) –  dannysauer Dec 11 '11 at 2:37
    
Nice post. Well written. –  Jeff F. Jun 19 '12 at 21:06
    
This doesn't work in Windoes 8.1 –  Milind R Oct 23 '13 at 7:51
1  
To expand on @MilindR's comment above, PAC files are still in Windows 8/IE11, but you need to load your PAC file from an HTTP or HTTPS URL, it can't just use a file based path or UNC. More information from the Internet Explorer team here Understanding Web Proxy Configuration and this answer has been updated to reflect IE11's changes. –  GAThrawn Oct 23 '13 at 10:01
add comment

Use Free IP Switcher 1.0

alt text

Description:

Whenever mobile user moves to different network, has to change particular IP address, gateway address, subnet mask, proxy server and default printer, etc., to particular network environment. In order to do it, he has to remember TCP/IP settings information of every network. Also, he has to reboot the computer to apply it to the system and to access the Internet.

Don't waste your time reconfiguring computer network settings every time you change your location. Free IP Switcher is a perfect solution for you. It switches between preconfigured network settings with a single click and without any reboot. With Free IP Switcher you can automatically change all network settings on your pc: IP address, network masks, default gateway, DNS server, wins server, proxy settings, default printer and more.

Features:

  • Switch IP network settings "on the fly" without restarting
  • Switch Internet Explorer proxy-server settings
  • Switch your default printer
  • Switch your computer name and workgroup
  • Import current network settings to the setting
  • System-tray icon support, auto-start with windows
  • 100% Spyware FREE, NOT contain any Spyware, Adware or Viruses
share|improve this answer
2  
I can't believe that something as useful as network configuration profiles has not already been made part of Windows 7. Ubuntu has it, Mac OS X has it . . . –  dreamlax Sep 24 '09 at 7:40
    
I know Dell made such a tool for my Latitude, but I disliked it :-( –  Ivo Flipse Sep 24 '09 at 8:20
    
The download version do not work for Windows / –  Hakan Forss Sep 26 '09 at 10:38
add comment

You have other (paid) alternatives to switching network configurations, like Mobile Net Switch or NetSetMan

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.