How can I make so that the gpupdate works in the service I have created?

Posted on 2011-05-12
Last Modified: 2012-05-11

I need help to get my service to update the GPO. I can do it manually by going to a cmd prompt and running 'gpupdate /force' and it works fine but when I try to run the same cmd via script it doesn't update the GPO like it should.

When i look in the event log it shows this for the description...
The Group Policy settings for the computer were processed successfully. New settings from 2 Group Policy objects were detected and applied.

If run it manually it shows up correctly in the registry and the event log shows this additional entry as it should...
The Group Policy settings for the user were processed successfully. New settings from 2 Group Policy objects were detected and applied.

Here is the code I am running in my Windows Service...
            Dim serviceProcess As New ProcessStartInfo
            serviceProcess.WindowStyle = ProcessWindowStyle.Hidden
            serviceProcess.FileName = "gpupdate.exe"
            serviceProcess.Arguments = "/Force"
            Dim servForceGPO As Process = Process.Start(serviceProcess)

            Dim strCommandLine As String = "gpupdate.exe /Force"
            Shell(strCommandLine, AppWinStyle.Hide)

Open in new window

Your assistance would be appreciated.

Question by:camoh

    Author Comment

    I forgot to mention above that I don't use both scripts at the same time. I am just showing you what I already tried and I get the same results for both...
    LVL 83

    Accepted Solution

    I think the problem is that the service is running under an account other than the current user hence the settings are not applied to the user's account. Are the settings user specific?

    Author Comment

    The Windows Service runs as Local System. The GPO settings force Internet proxy settings and this appears to need to happen on the user side. I thought gpupdate /force is to update all GPO settings across the board. I need to find some consistent way to push this out.
    LVL 83

    Assisted Solution

    I think gpupdate refreshes the system wide settings but it only refreshes user settings for the current user. I may be wrong though.

    Author Comment

    Do you think that 'gpupdate /target:user' would work to force the user's GPO settings?
    LVL 83

    Expert Comment

    I hope it does. Give that a try.

    Assisted Solution

    That ends up being a SYSTEM user as well. :(

    I am trying other options... hopefully soon I can post back when I find what works for me...

    Author Closing Comment

    I was not able to get gpupdate to work like I had wanted to so I changed my method of doing things to checking the registry instead.

    Thank you for helping me with this!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Suggested Solutions

    This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
    It’s quite interesting for me as I worked with Excel using for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

    759 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

    13 Experts available now in Live!

    Get 1:1 Help Now