/build/static/layout/Breadcrumb_cap_w.png

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.


2 Comments   [ + ] Show comments
  • 'Define Variables and Objects.
    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
  • Are you looking to use Kace scripting? - jegolf 9 years ago

Answers (4)

Posted by: SMal.tmcc 9 years ago
Red Belt
2
Ok gpupdate basics then on to your script. 

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
lA9peI.jpeg
Here is with a force
deE0UL.jpeg
Then add either the /logoff switch if only user policies have changed or the /boot switch for both policies.


GTVTDP.jpeg

YX0ZWs.jpeg

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.




Posted by: Kdebiasse 9 years ago
9th Degree Black Belt
0

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
Posted by: Kdebiasse 9 years ago
9th Degree Black Belt
0
Got it to work. Thank everyone that answered the question.,
Posted by: Kdebiasse 9 years ago
9th Degree Black Belt
0
Got it to work. Thank everyone that answered the question.,

Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login

View more:

Share

 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ