Jump to content
Sign in to follow this  

GPUpdate with COM Object

Recommended Posts


Hello Guys,

I have an little Problem maybe you could help me.

I want to make an GPUpdate with Autoit.

This time my Function looks like that, but this is not perfect.

Func gpUpdate()
    $gpupdate = Run(@ComSpec & " /c gpupdate /force")
    For $i = 0 To 30
        If Not ProcessExists($gpupdate) Then
EndFunc   ;==>gpUpdate")

I want to use an COM Object but I have no idea how to use this functions right way.


maybe someone can write an example script/function? 

I found this script already in web, but it only push the PC to update Group Policy an I don't know is it ready or not and does it requires an reboot.

Global Const $RP_FORCE = 1

$bMachine = 0
;[in] Specifies whether to refresh the computer policy or user policy. If this value is TRUE, the system refreshes the computer policy. If this value is FALSE, the system refreshes the user policy.

Dim $Return

$Return = DllCAll("Userenv.dll","int","RefreshPolicyEx","int",$bMachine,"int",$RP_FORCE)

If IsArray($Return) Then
    ConsoleWrite("Function Returned: " & $Return[0] & @LF)
    Msgbox(64,"The Function Returned:","The function returned : " & $Return[0] & @CRLF & "If the value returned was not zero then the function succeeded.")
    ConsoleWrite("DllCall didn't return an array.  The call was therefore unsuccessful." & @LF)
    MsgBox(16,"Error!","The Dll Call was unsuccessful because it did not return an array.")

Thank you for your help


PS: I know my english is not perfect but I hope you have unterstood my problem.


Share this post

Link to post
Share on other sites


thank you for your idea, but I only want to know the "Errorlevel" of gpUpdate sometimes the Group policys does not work right way.

I don't want to restart automaticly or simular. only want to know GPs are correct or not.


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this