Avatar of samirst
samirst
 asked on

Start up Script for Proxy selection in IE7

Hi Experts,
I am using a proxy server when connecting to the internet, however, evey time I reboot my computer, the Proxy selection tick box in Internet Properties>Connections>LAN Settings de-selects itself and I am having to go in and select it every time I reboot. Is there a way of keeping this 'Use a Proxy Server for your LAN' option selected all the time? May be a start up script that selects it on reboot. Would appreciate the script coding and how I can set it up to run on startup.
Many thanks
Sam
Web BrowsersVB ScriptScripting Languages

Avatar of undefined
Last Comment
samirst

8/22/2022 - Mon
manav08

Hi Mate,

Assumming my proxy is 192.168.101.1:8080.
attached is the code I have been using for ages. Just copy the code into a notepad file and rename it something like proxychanger.vbs
Double click on it to RUN.
Const HKCU=&H80000001 'HKEY_CURRENT_USER
Const HKLM=&H80000002 'HKEY_LOCAL_MACHINE
 
Const REG_SZ=1
Const REG_EXPAND_SZ=2
Const REG_BINARY=3
Const REG_DWORD=4
Const REG_MULTI_SZ=7
 
Const 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 "Proxy Disabled"
Else
' If Proxy is not set then turn it on
 
strProxyServer = "192.168.101.1:8080"
strProxyOveride = "*.domain.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 "Proxy Enabled" & vbcrlf & "(" & strProxyServer & ")"
End If
 
End 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 Function
 
Function DeleteValue(Key, SubKey, ValueName)
DeleteValue = oReg.DeleteValue(Key,SubKey,ValueName)
End Function
 
Function 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 Select
 
GetValue = Ret
End Function

Open in new window

samirst

ASKER
Thank you, how do I get it to automatically run on start up?
ASKER CERTIFIED SOLUTION
manav08

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
samirst

ASKER
This is great, thank you very much for your help
Sam
Your help has saved me hundreds of hours of internet surfing.
fblack61