Users who use VPN to connect to work from home often have problems trying to connect to the internet using their web browser when they disconnect from the VPN. It is usually caused when a proxy is automatically configured for them in their web browser (ie. Tools –> Internet Options –> Connections –> LAN Settings). This script is set to enable the proxy if it is disabled and will disable the proxy if it is enabled click here to download or copy and paste from below (some browsers change the quote characters so check that if the script doesn’t run as expected).
‘Enable and Disable IE Proxy
Const HKCU=&H80000001 ‘HKEY_CURRENT_USER
Const HKLM=&H80000002 ‘HKEY_LOCAL_MACHINEConst REG_SZ=1
Const REG_EXPAND_SZ=2
Const REG_BINARY=3
Const REG_DWORD=4
Const REG_MULTI_SZ=7Const HKCU_IE_PROXY = “Software\Microsoft\Windows\CurrentVersion\Internet Settings”
Set oReg=GetObject(“winmgmts:!root/default:StdRegProv”)
Main
Sub Main()
‘ If Proxy is set then turn it off
If GetValue(HKCU,HKCU_IE_PROXY,”ProxyEnable”,REG_DWORD) = 1 And _
Len(GetValue(HKCU,HKCU_IE_PROXY,”ProxyServer”,REG_SZ)) > 0 Then
CreateValue HKCU,HKCU_IE_PROXY,”ProxyEnable”,0,REG_DWORD
wscript.echo “Banner Proxy Disabled”
Else
‘ If Proxy is not set then turn it onstrProxyServer = “azproxy02.bhs.bannerhealth.com:8080″
strProxyOveride = “*.bannerhealth.com;*.domain2.com;*domain3.com”CreateValue HKCU,HKCU_IE_PROXY,”ProxyServer”,strProxyServer,REG_SZ
CreateValue HKCU,HKCU_IE_PROXY,”ProxyEnable”,1,REG_DWORD
CreateValue HKCU,HKCU_IE_PROXY,”ProxyOverride”,strProxyOveride,REG_SZ
wscript.echo “Banner Proxy Enabled” & vbcrlf & “(” & strProxyServer & “)”
End IfEnd Sub
Function CreateValue(Key,SubKey,ValueName,Value,KeyType)
Select Case KeyType
Case REG_SZ
CreateValue = oReg.SetStringValue(Key,SubKey,ValueName,Value)
Case REG_EXPAND_SZ
CreateValue = oReg.SetExpandedStringValue(Key,SubKey,ValueName,Value)
Case REG_BINARY
CreateValue = oReg.SetBinaryValue(Key,SubKey,ValueName,Value)
Case REG_DWORD
CreateValue = oReg.SetDWORDValue(Key,SubKey,ValueName,Value)
Case REG_MULTI_SZ
CreateValue = oReg.SetMultiStringValue(Key,SubKey,ValueName,Value)
End Select
End FunctionFunction DeleteValue(Key, SubKey, ValueName)
DeleteValue = oReg.DeleteValue(Key,SubKey,ValueName)
End FunctionFunction GetValue(Key, SubKey, ValueName, KeyType)
Dim Ret
Select Case KeyType
Case REG_SZ
oReg.GetStringValue Key, SubKey, ValueName, Value
Ret = Value
Case REG_EXPAND_SZ
oReg.GetExpandedStringValue Key, SubKey, ValueName, Value
Ret = Value
Case REG_BINARY
oReg.GetBinaryValue Key, SubKey, ValueName, Value
Ret = Value
Case REG_DWORD
oReg.GetDWORDValue Key, SubKey, ValueName, Value
Ret = Value
Case REG_MULTI_SZ
oReg.GetMultiStringValue Key, SubKey, ValueName, Value
Ret = Value
End SelectGetValue = Ret
End Function