• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1062
  • Last Modified:

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

Hi,

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 vb.net 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 vb.net 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)
            servForceGPO.WaitForExit()
            servForceGPO.Close()

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

Open in new window


Your assistance would be appreciated.


0
camoh
Asked:
camoh
  • 5
  • 3
3 Solutions
 
camohAuthor Commented:
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...
0
 
CodeCruiserCommented:
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?
0
 
camohAuthor Commented:
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.
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
CodeCruiserCommented:
I think gpupdate refreshes the system wide settings but it only refreshes user settings for the current user. I may be wrong though.
0
 
camohAuthor Commented:
Do you think that 'gpupdate /target:user' would work to force the user's GPO settings?
0
 
CodeCruiserCommented:
I hope it does. Give that a try.
0
 
camohAuthor Commented:
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...
0
 
camohAuthor Commented:
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!
0

Featured Post

Learn to develop an Android App

Want to increase your earning potential in 2018? Pad your resume with app building experience. Learn how with this hands-on course.

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now