Does anyone know of a scriptable way to switch Internet Proxy LAN Settings for browsers

4

3

I have two networks at work and when I have to use my Wireless settings I need IE to use one set of Proxy LAN Settings, and when I am plugged in I need a different set.


I have been looking for a way to script in the Proxy Settings:

HTTP, FTP and Secure

I also need the "exemptions"

I can't buy anything....my company is in a buying pinch. And my IT guys groaned when I asked if I could install FireFox...because I was going to use Firefox for Wireless, IE for LAN....but they yelled at me.

Edit: I can't install anything for this. This is a "non issue" to my IT guys.
Edit: I have IE 8 installed

NighTerrorX

Posted 2009-07-30T14:08:48.410

Reputation: 275

Let me quess: you're not allowed to install any software to do this? – Ivo Flipse – 2009-07-30T14:16:34.837

Oh and what version of IE do you have? – Ivo Flipse – 2009-07-30T14:17:46.393

Owh did I mention that you probably need admin settings to get the "cool" solutions? – Ivo Flipse – 2009-07-30T14:21:15.033

Answers

4

Absolutely!

Almost all programs these days keep their settings within the registry somewhere. So if it is in the registry and you want to automate it you are in luck.

The first step is to find the registry keys that contain the specific configuration that you are going to automate. Once you have the registry keys identified, export those keys to a REG file type. Then write yourself a script which will call the .REG file from the command line.

The example REG file content below thanks to Ivo

Regedit4

[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>"

An example to actually put the contents of the REG file within the registry is...

C:> REGSRV32 myregsettings.REG

If it prompts you for a response such as a Y/N question use the following example instead

C:> REGSRV32 myregistrysettings.REG < yes.txt

where yes.txt is you should create a text file which contains the Y character and a carriage return to complete the response.

Axxmasterr

Posted 2009-07-30T14:08:48.410

Reputation: 7 584

1Axx, how about you add the registry part from my post to yours? That would make the most complete post! – Ivo Flipse – 2009-07-30T14:24:18.587

Or look at this knowledge base: http://support.microsoft.com/?id=819961

– Ivo Flipse – 2009-07-30T14:26:38.103

2

Now I really hate network settings, so I can't guarantee it works.

Push the Browser Settings in the Login Script (for Internet Explorer)

Internet Explorer stores proxy settings in the registry. This makes it particularly easy to update, using a variety of methods. Even if your users do not normally use Internet Explorer as their usual browser, you will want to configure the proxy settings because many other applications key off proxy settings in Internet Explorer.

In this method, you determine the proper registry key for your version of IE, export the settings to a .REG file, and then use REGEDIT in the login script to push the settings to the PC.

To create the SETPXY.REG file, open notepad & type in as follows:

REGEDIT4 (or whatever version of REGEDIT is on your PC, such as REGEDT32)
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings]
"ProxyServer"="<your proxy IP address>:8080"
"ProxyEnable"=dword:00000001
"ProxyOverride"="<local>"

Change to the private IP address of your HTTP Proxy, and to 127.0.0.1 or any combination of URL's for which you want to bypass the proxy. (I advise you to experiment with this for a while to get the syntax done correctly).

Check this Knowledge Base post for more info on the registry part.

Ivo Flipse

Posted 2009-07-30T14:08:48.410

Reputation: 24 054

1

For little money there is Mobile Net Switch which can manage whole network setting profiles including proxy settings. I use it for some time and could not find any better (free) software.

desolat

Posted 2009-07-30T14:08:48.410

Reputation: 902

1

You should try a pac file. I asked this question on ServerFault.com.

Here is the answer I accepted:

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.

Jeff Yates

Posted 2009-07-30T14:08:48.410

Reputation: 1 518

0

Make a EnableProxy.bat file with the following content:

@reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /f /v ProxyEnable /t REG_DWORD /d 1

and DisableProxy.bat

@reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /f /v ProxyEnable /t REG_DWORD /d 0

This will just enable/disable the proxy, if you'd like to also change server address add another line to EnableProxy.bat

@reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /f /v ProxyServer /t REG_SZ /d your.proxy.server

Using REG enables you to change individual settings in a silent manner (/f switch) and it requires no UAC prompt (probably because this example only modifies HKCU).

Boris B.

Posted 2009-07-30T14:08:48.410

Reputation: 325