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

GPUpdate /force VBS

Hi

I need to run a GPUpdate /force in VBS as part of the Computer Startup Script. Is this possible? Reason I ask is because PC's do not appear to be syncing to our GPO's correctly, so at the moment I'm having to run a gpupdate /force on all users PC's manually.

I have got a batch file, but would prefer to have this in my VBS.
CD\
echo No|gpupdate /force

Any ideas?

Thanks.
0
mishcondereya
Asked:
mishcondereya
  • 3
  • 3
1 Solution
 
merowingerCommented:
sure!


set objShell = CreateObject("Wscript.Shell")
objShell.Run "gpupdate /force",0,true
0
 
mishcondereyaAuthor Commented:
Cool.

I copied the above into a test VBS, but the wscript.exe has been in my task manager for at least 4 minutes now. When I run GPupdate from cmd manually and say NO to log off, it only takes about 40 seconds.

Could it be waiting for some kind of user input, but in the background? Or has this script been specifically designed for the Computer Startup Script only, and not to be used during Windows?

Thanks.
0
 
merowingerCommented:
The script is waiting for the gpupdate.exe. I assume it is the "please logoff message"


The following will just exeute the command and then stop processing:

objShell.Run "gpupdate /force",0,false
0
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
mishcondereyaAuthor Commented:
Just checked in the event viewer and there was an event that says "Security policy in the Group policy objects has been applied successfully."

So I'm assuming that it did run, but only when applied to the Computer Startup Script?

Silly question, but what is the difference between True and False. Do they both do what I want, but False bypasses the "please logoff message"?
0
 
merowingerCommented:
Yes of course. It has been executed successfully, the only problem was that the gpupdate.exe waited for some user input. I assume the "logoff message"

The difference is that if you choose "true". The wscript.exe will wait until the gpupdate.exe is closed. If you choose "false" it will not wait and just close independed of the gpudpate.exe.

If you run the script with user rights (user logon script) it will update the user policy part. If you run it with computer rights (computer starup script) it will update the computer policy part.
0
 
mishcondereyaAuthor Commented:
Too good!!
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

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