VBScript - Toggle Proxy Server
This is a very simple script that toggles the ProxyEnable registry key. I run this script when I connect and disconnect from my corporate network.
Const HKEY_CURRENT_USER = &H80000001
strComputer = "."
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
strComputer & "\root\default:StdRegProv")
strKeyPath = "Software\Microsoft\Windows\CurrentVersion\Internet Settings"
strValueName = "ProxyEnable"
oReg.GetDWORDValue HKEY_CURRENT_USER,strKeyPath,strValueName,dwValue
If dwValue = 0 Then
dwValue = 1
oReg.SetDWORDValue HKEY_CURRENT_USER,strKeyPath,strValueName,dwValue
msgbox "The proxy server was off, it is now on"
Else
dwValue = 0
oReg.SetDWORDValue HKEY_CURRENT_USER,strKeyPath,strValueName,dwValue
msgbox "Proxy was on, it is now off"
End If
Ben’s Tech Blog » Blog Archive » Scripts page said,
February 13, 2006 @ 10:28 pm
[…] I’ve created a page for script examples and have posted a script there. I’ll add some more in the near future. VBScript - Toggle proxy server Permalink […]
Scott Vickrey said,
August 29, 2007 @ 12:30 am
Thanks for sharing Ben. This script works great.
proxy script said,
February 22, 2008 @ 2:27 pm
Yes, That really useful Thanks!