Toggle Windows Proxy Settings

December 19th, 2008

If you use a laptop both at home and at work it gets really annoying having to switch between using and not using a proxy server to connect to the internet.

Having found quite a few sites explaining how to get the ProxyEnable registry value it’s pretty trivial to make a VBScript that toggles the flag on and off. Just save this script in a file with a .vbs extension and double click to run. Each time it runs it will just toggle the proxy on and off .

I could write the usual warning about modifying the registry but we’re all adults here….

Const HKEY_CURRENT_USER = &H80000001
strComputer = "."
Set objRegistry = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")
strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings"
strValueName = "ProxyEnable"
objRegistry.GetDWORDValue HKEY_CURRENT_USER, strKeyPath, strValueName, dwValue
if dwValue=0 then
	dwValue=1
else
	dwValue=0
end if
objRegistry.SetDWORDValue HKEY_CURRENT_USER, strKeyPath, strValueName, dwValue
if dwValue=1 then
	msg="Proxy Enabled"
else
	msg="Proxy Disabled"
end if
msgbox msg,64,"Proxy Toggle"
Google BookmarksEvernoteGoogle GmailHotmailWordPressLinkedInFacebookDeliciousShare

4 responses

  1. bobpeers -> blog » QuickProxy for Firefox pings back:

    [...] I wrote previously about toggling the proxy setting in Internet Explorer I looked for a similar function for [...]

  2. christian comments:

    Your script would be exactly what I’m looking for, but apparently your blog ate some of the backslashes. (At least on line 3 and 4).

    I can’t get it to work currently. Do you have to fill in a computer name on line 2?

  3. Bob Peers comments:

    Hi Christian,

    sorry about that, I’ve made my blog regurgitate the backslashes! And no you do not need to enter the computer name, just use as is.

    Bob

  4. Dave comments:

    It literally took me 5 seconds to paste this into notepad and save. Thanks – it’s just what I needed!

Leave a comment

Switch to our mobile site