We help IT Professionals succeed at work.

vbs script not working with Group Policy

BartowIT asked
Medium Priority
Last Modified: 2012-05-06
Within our environment all of our EIs use a Proxy server to access the internet. We also have a few users that have laptops and when they take them home they can not browse the internet since EI is looking for the proxy server. We have created a container within active directory and put all laptops within. We also created a group policy that will execute a logon and logoff vbs script that should set the proxy and then unset it. When we manually run the scripts all works fine. When running from the gp not all variables are set. The address and port are not populated. I was hopping someone could shed some light or adjust the script for it to work properly.

Const HKEY_CURRENT_USER = &H80000001

strComputer = "."
Set objRegistry = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")
strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings"

strValueName = "ProxyEnable"
dwValue = 1
objRegistry.SetDWORDValue HKEY_CURRENT_USER, strKeyPath, strValueName, dwValue

strValueName = "ProxyServer"
strValue = "cssapps1:8080"
objRegistry.SetStringValue HKEY_CURRENT_USER, strKeyPath, strValueName, strValue

strValueName = "ProxyOverride"
strValue = "<local>"
objRegistry.SetStringValue HKEY_CURRENT_USER, strKeyPath, strValueName, strValue


ProxyEnable and ProxyOverride are set in the registry but ProxyServer does not.

Thanks for your time,
Watch Question

Todd GerbertSenior Engineer
Top Expert 2010

It shouldn't matter, but maybe using the WScript.Shell object might work better...could be a permissions issue with WMI...?

Also, I'm thinking as long as ProxyEnable is set appropriately, you can leave the others set all the time.

And, of course, there's always auto-configure for the proxy settings, though I've never set it up myself.
Set WshShell = CreateObject("WScript.Shell")
strKeyPath = "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\"
WshShell.RegWrite strKeyPath & "ProxyEnable", 1, "REG_DWORD"
WshShell.RegWrite strKeyPath & "ProxyServer", "cssapps1:8080", "REG_SZ"
WshShell.RegWrite strKeyPath & "ProxyOverride", "<local>", "REG_SZ"

Open in new window

Ok After more testing and googling I found out what was happening. I had to update the group policy its self. I had to Navigate to Computer Configuration > Administrative Templates > System > Group Policy and Enable User Group Policy loopback processing mode. I also Enable "Run startup scripts visible"

All works fine.

Thanks for your help,

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.