How to switch proxy settings via script?

There are a number of users in our organization that use their laptops on multiple networks. Each network has its own proxy setting requirements for accessing the Internet and currently, the users must manually change these settings in Internet Settings whenever moving to a different network.

Is it possible to script the changes so that the user can just run the appropriate script for the network they're on?

This is primarily for Windows XP but might also be required for Vista and Windows 7.


Solution 1:

Look into proxy auto-config scripts. You can script changes to the Windows registry to select a different proxy server, but you'll really like proxy auto-config scripts and how they work on your client computers.

http://en.wikipedia.org/wiki/Proxy_auto-config

I moved to proxy auto-config files for my school district Customer a couple of years ago as a result of administrators taking laptops off-site and trying to work on other networks that didn't need an HTTP proxy specified. It's worked like a charm, and is a nice cross-browser and cross-platform compatible solution.

Solution 2:

Microsoft kb 819961 is a good starting point.

The registry settings for the browser are located here.

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings]
"MigrateProxy"=dword:00000001
"ProxyEnable"=dword:00000001
"ProxyHttp1.1"=dword:00000000
"ProxyServer"="http://ProxyServername:80"
"ProxyOverride"="<local>"

It should be pretty easy to build a vbs or powershell script to automatically update the registry.