vbs script not working with Group Policy

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,
Dan
BartowITAsked:
Who is Participating?
 
BartowITConnect With a Mentor Author Commented:
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,
Dan
0
 
Todd GerbertIT ConsultantCommented:
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

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.