nitro322 Posted October 24, 2006 Share Posted October 24, 2006 I'm trying to automate an uninstallation process. I first need to wait for the uninstaller to complete, then perform some other cleanup actions. RunWait() is obviously what I would usually use for this, but this particular uninstaller spawns a randomly-named copy of itself in %temp%, calls the new copy, then exits. So, runwait() finishes before the app is uninstalled. Since I cannot predict the uninstaller filename, I figure my next best option would be to use a processwaitclose() on the PID. Unfortunately I cannot figure out how to get the PID of this child process. Using run() on the uninstaller returns the PID of the original process, not the process that actually performs the uninstallation. Any suggestions? I know that this basic issue has been addressed many times in the past, but I was unable to find the answer to this particular problem in my search. Thanks. http://www.legroom.net/ Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted October 24, 2006 Moderators Share Posted October 24, 2006 http://www.autoitscript.com/forum/index.ph...st&p=215406 Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
GaryFrost Posted October 24, 2006 Share Posted October 24, 2006 Could use a where clause in this on the ParentID expandcollapse popup; Generated by AutoIt Scriptomatic $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $colItems = "" $strComputer = "localhost" $Output="" $Output = $Output & "Computer: " & $strComputer & @CRLF $Output = $Output & "==========================================" & @CRLF $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_Process", "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) then For $objItem In $colItems $Output = $Output & "Caption: " & $objItem.Caption & @CRLF $Output = $Output & "CommandLine: " & $objItem.CommandLine & @CRLF $Output = $Output & "CreationClassName: " & $objItem.CreationClassName & @CRLF $Output = $Output & "CreationDate: " & WMIDateStringToDate($objItem.CreationDate) & @CRLF $Output = $Output & "CSCreationClassName: " & $objItem.CSCreationClassName & @CRLF $Output = $Output & "CSName: " & $objItem.CSName & @CRLF $Output = $Output & "Description: " & $objItem.Description & @CRLF $Output = $Output & "ExecutablePath: " & $objItem.ExecutablePath & @CRLF $Output = $Output & "ExecutionState: " & $objItem.ExecutionState & @CRLF $Output = $Output & "Handle: " & $objItem.Handle & @CRLF $Output = $Output & "HandleCount: " & $objItem.HandleCount & @CRLF $Output = $Output & "InstallDate: " & WMIDateStringToDate($objItem.InstallDate) & @CRLF $Output = $Output & "KernelModeTime: " & $objItem.KernelModeTime & @CRLF $Output = $Output & "MaximumWorkingSetSize: " & $objItem.MaximumWorkingSetSize & @CRLF $Output = $Output & "MinimumWorkingSetSize: " & $objItem.MinimumWorkingSetSize & @CRLF $Output = $Output & "Name: " & $objItem.Name & @CRLF $Output = $Output & "OSCreationClassName: " & $objItem.OSCreationClassName & @CRLF $Output = $Output & "OSName: " & $objItem.OSName & @CRLF $Output = $Output & "OtherOperationCount: " & $objItem.OtherOperationCount & @CRLF $Output = $Output & "OtherTransferCount: " & $objItem.OtherTransferCount & @CRLF $Output = $Output & "PageFaults: " & $objItem.PageFaults & @CRLF $Output = $Output & "PageFileUsage: " & $objItem.PageFileUsage & @CRLF $Output = $Output & "ParentProcessId: " & $objItem.ParentProcessId & @CRLF $Output = $Output & "PeakPageFileUsage: " & $objItem.PeakPageFileUsage & @CRLF $Output = $Output & "PeakVirtualSize: " & $objItem.PeakVirtualSize & @CRLF $Output = $Output & "PeakWorkingSetSize: " & $objItem.PeakWorkingSetSize & @CRLF $Output = $Output & "Priority: " & $objItem.Priority & @CRLF $Output = $Output & "PrivatePageCount: " & $objItem.PrivatePageCount & @CRLF $Output = $Output & "ProcessId: " & $objItem.ProcessId & @CRLF $Output = $Output & "QuotaNonPagedPoolUsage: " & $objItem.QuotaNonPagedPoolUsage & @CRLF $Output = $Output & "QuotaPagedPoolUsage: " & $objItem.QuotaPagedPoolUsage & @CRLF $Output = $Output & "QuotaPeakNonPagedPoolUsage: " & $objItem.QuotaPeakNonPagedPoolUsage & @CRLF $Output = $Output & "QuotaPeakPagedPoolUsage: " & $objItem.QuotaPeakPagedPoolUsage & @CRLF $Output = $Output & "ReadOperationCount: " & $objItem.ReadOperationCount & @CRLF $Output = $Output & "ReadTransferCount: " & $objItem.ReadTransferCount & @CRLF $Output = $Output & "SessionId: " & $objItem.SessionId & @CRLF $Output = $Output & "Status: " & $objItem.Status & @CRLF $Output = $Output & "TerminationDate: " & WMIDateStringToDate($objItem.TerminationDate) & @CRLF $Output = $Output & "ThreadCount: " & $objItem.ThreadCount & @CRLF $Output = $Output & "UserModeTime: " & $objItem.UserModeTime & @CRLF $Output = $Output & "VirtualSize: " & $objItem.VirtualSize & @CRLF $Output = $Output & "WindowsVersion: " & $objItem.WindowsVersion & @CRLF $Output = $Output & "WorkingSetSize: " & $objItem.WorkingSetSize & @CRLF $Output = $Output & "WriteOperationCount: " & $objItem.WriteOperationCount & @CRLF $Output = $Output & "WriteTransferCount: " & $objItem.WriteTransferCount & @CRLF if Msgbox(1,"WMI Output",$Output) = 2 then ExitLoop $Output="" Next Else Msgbox(0,"WMI Output","No WMI Objects Found for class: " & "Win32_Process" ) Endif Func WMIDateStringToDate($dtmDate) Return (StringMid($dtmDate, 5, 2) & "/" & _ StringMid($dtmDate, 7, 2) & "/" & StringLeft($dtmDate, 4) _ & " " & StringMid($dtmDate, 9, 2) & ":" & StringMid($dtmDate, 11, 2) & ":" & StringMid($dtmDate,13, 2)) EndFunc SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
nitro322 Posted October 24, 2006 Author Share Posted October 24, 2006 Thanks for the response. This looks like what I need, but it's not working quite right. Eg: $pid = run("uninst.exe") processwaitclose($pid) <WMI code SNIP> For $objItem in $colItems ;if $pid == $objItem.ParentProcessId then $Output = "Name: " & $objItem.Name & @CRLF $Output &= "ParentProcessId: " & $objItem.ParentProcessId & @CRLF $Output &= "ProcessId: " & $objItem.ProcessId msgbox(0, $pid, $output) ;endif Next If I leave that if statement checking for a match against the parent ID, it never finds one. I commented it out and looked for the program manually and got this: uninst.exe PID = 1476 spawned PID = 1384 spawned Parent PID = 1164 So, for some reason the spawned uninstaller's parent PID does not match up to the original uninstaller's PID. In fact, 1164 does not show up anywhere in my list of running process (neither does 1476, but that's to be expected). So, where is this parent PID coming from? I guess it's possible that uninst.exe is spawning a child process, which then spawns another child process, but that seems like overkill. Are there any other explanations? Alternatively, does anyone have another suggestion to make AutoIt wait until the uninstaller has completed? http://www.legroom.net/ Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now