Need a script to do GPUdate force
I need two scripts one that will do GPUpdate /force then reboot PC
and one that does
GPUdate /force without reboot.
Answers (4)
You are doing the user separately, no need to run 2 commands.
Be aware that doing a /force on a lot of machines at the same time can cause problems with your DC's and the network.
It needs to be an online script for the user to update
here is the easy way to do gpupdate via KScript on v3.7
Here is with a force
Then add either the /logoff switch if only user policies have changed or the /boot switch for both policies.
Description: Updates Group Policies settings.
Syntax: GPUpdate [/Target:{Computer | User}] [/Force] [/Wait:<value>]
[/Logoff] [/Boot] [/Sync]
Parameters:
Value Description
/Target:{Computer | User} Specifies that only User or only Computer
policy settings are updated. By default,
both User and Computer policy settings are
updated.
/Force Reapplies all policy settings. By default,
only policy settings that have changed are
applied.
/Wait:{value} Sets the number of seconds to wait for policy
processing to finish. The default is 600
seconds. The value '0' means not to wait.
The value '-1' means to wait indefinitely.
When the time limit is exceeded, the command
prompt returns, but policy processing
continues.
/Logoff Causes a logoff after the Group Policy settings
have been updated. This is required for
those Group Policy client-side extensions
that do not process policy on a background
update cycle but do process policy when a
user logs on. Examples include user-targeted
Software Installation and Folder Redirection.
This option has no effect if there are no
extensions called that require a logoff.
/Boot Causes a computer restart after the Group Policy settings
are applied. This is required for those
Group Policy client-side extensions that do
not process policy on a background update cycle
but do process policy at computer startup.
Examples include computer-targeted Software
Installation. This option has no effect if
there are no extensions called that require
a restart.
/Sync Causes the next foreground policy application to
be done synchronously. Foreground policy
applications occur at computer boot and user
logon. You can specify this for the user,
computer or both using the /Target parameter.
The /Force and /Wait parameters will be ignored
if specified.
I found this and it works for no logoff. But I want it to exit cmd prompt. Cmd prompt is still open and up. user will have to exit cmd prompt and I don't want user to do anything.
'====================
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("WScript.Shell")
strInputFile = Replace(WScript.ScriptFullName, WScript.ScriptName, "") & "input.txt"
Set objInputFile = objFSO.CreateTextFile(strInputFile, True)
objInputFile.WriteLine "n"
objInputFile.WriteLine "n"
objInputFile.Close
Set objInputFile = Nothing
strInputFile = objFSO.GetFile(strInputFile).ShortPath
' FOR TESTING, USE /k and 1, AFTER TESTING, USE /c and 0
strCommand = "cmd /k gpupdate /force < " & strInputFile
objShell.Run strCommand, 1, True
objFSO.DeleteFile strInputFile, True
Set objFSO = Nothing
Set objShell = Nothing
' The line below can be commented out when you have finished testing to keep it silent.
MsgBox "Script finished."
'====================
Comments:
-
Hi there,
Is this a BAT or VBS script.
How do i run it if i had to, as a post install task in the k2000 ?
Thanks. - akmagnum 8 years ago
Set WshShell = CreateObject("Wscript.Shell")
'Note: Gpupdate command has to be run twice as the ECHO command can't answer more than one question.
'Refresh the USER policies and also answer no to logoff if asked.
'Result = WshShell.Run("cmd /c echo n | gpupdate /target:user /force",0,true)
'Refresh the Computer policies and answer no to reboot.
Result = WshShell.Run("cmd /c echo n | gpupdate /target:computer /force",0,true)
'Hand back the errorlevel
Wscript.Quit(Result) - Kdebiasse 9 years ago