vbs script not working with Group Policy

Posted on 2009-02-19
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,
Question by:BartowIT
    LVL 33

    Expert Comment

    by:Todd Gerbert
    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


    Accepted Solution

    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,

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    We were having a lot of "Heartbeat Alerts" in our SCOM environment, now "Heartbeat" in a SCOM environment for those of you who might not be familiar with SCOM is a packet of data sent from the agent to the management server on a regular basis, basic…
    This collection of functions covers all the normal rounding methods of just about any numeric value.
    The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
    The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    9 Experts available now in Live!

    Get 1:1 Help Now