Vbscript change proxy setting at logon
Posted on 2005-04-07
I have a Vbscript that runs different a command depending on your IP Address I need this because I move between a number of different networks, some have a proxy and some don not.
It does things like add printers, maps drives etc. but one thing I can not get to work is enable or disable the proxy.
It works fine if you run the script manually but not at logon. I have striped the code down to just the proxy bit for troubleshooting.
My proxy.vbs file is in c:\proxy.vbs and configured via local computer Group Policy to run at logon. I have local and domain admin rights.
User Configuration\Windows Settings\Scripts (Logon/Logoff)\Logon
'Here is the Proxy code
Set ShellObj = WScript.CreateObject("WScript.Shell")
ShellObj.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyServer", "192.168.0.156:8080", "REG_SZ"
ShellObj.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyEnable", 0, "REG_DWORD"
ShellObj.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyOverride", "192.168.*;<local>", "REG_SZ"