Jump to content

Recommended Posts

Posted

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
            ExitLoop
        EndIf
        Sleep(1000)
    Next
    ProcessClose($gpupdate)
EndFunc   ;==>gpUpdate")

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

http://msdn.microsoft.com/en-us/library/windows/desktop/aa374154(v=vs.85).aspx

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.")
Else
    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.")
EndIf

Thank you for your help

CK

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

 

  • Moderators
Posted

Why is gpupdate not working for you? I use this all the time:

ShellExecuteWait("gpupdate.exe", "/Force /Logoff", "", "", @SW_HIDE)

If I need to hit a remote machine I use PSExec

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Posted

Hi,

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.

CK

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...