Link to home
Start Free TrialLog in
Avatar of mishcondereya
mishcondereyaFlag for United Kingdom of Great Britain and Northern Ireland

asked on

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.
Avatar of merowinger
merowinger
Flag of Germany image

sure!


set objShell = CreateObject("Wscript.Shell")
objShell.Run "gpupdate /force",0,true
Avatar of mishcondereya

ASKER

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.
ASKER CERTIFIED SOLUTION
Avatar of merowinger
merowinger
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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"?
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.
Too good!!