Toggle Windows Proxy Settings
December 19th, 2008If 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"
February 13th, 2009 at 11:17 am
[...] I wrote previously about toggling the proxy setting in Internet Explorer I looked for a similar function for [...]
May 5th, 2009 at 8:54 am
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?
May 5th, 2009 at 1:16 pm
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
July 20th, 2011 at 5:03 pm
It literally took me 5 seconds to paste this into notepad and save. Thanks – it’s just what I needed!