Sign in to follow this  
Followers 0
darkjohn20

Getting most recent process

8 posts in this topic

Say I had 2 processes named "Process.exe" and "Process.exe".

Using

ProcessList("Process.exe")

would give me both of them along with their PIDs.

I need to determine which one has been running longer. How can I achieve this? (I assume with winmgmts and ExecQuery)

My code (It's not much):

$Processes = ProcessList("Process.exe")
Local $Times[$Processes[0][0]]

For $P = 1 To $Processes[0][0]
    $Times[$P-1] = ;Get how long process has been running.
Next

;Code to sort it or split strings if in a HH:MM:SS format or whatever. (I'm not sure what format it will be in)
;This part is easy once I have the times.

Share this post


Link to post
Share on other sites



Well, the way I would go about doing it would be getting a command line process viewer, and using that to get the creation time for the two processes with Run().

Of course there's probably a wmi/WINAPI option that I don't know about, but I come from a *nix background and I tend to go with the 'call the small utility' approach to problem solving.


#fgpkerw4kcmnq2mns1ax7ilndopen (Q, $0); while ($l = <Q>){if ($l =~ m/^#.*/){$l =~ tr/a-z1-9#/Huh, Junketeer's Alternate Pro Ace /; print $l;}}close (Q);[code] tag ninja!

Share this post


Link to post
Share on other sites

Thanks, but I'd rather go with a winAPI option.

I found this:

http://www.bigresource.com/Tracker/Track-vb-PAz63Ay9c4/

Could I get a little help converting it? :(

I'll work on it in the mean time because I know this forum likes that!

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Look at _ProcessListProperties(). The process creation Date/Time is listed in [n][8] of the array.

:)

Edit: Ooh. I like the DLL calls in the WinAPIEx UDF. The _ProcessListProperties() function is all WMI.

:(

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Wow...How did I not see either of these....Will take a look. Thanks!

Share this post


Link to post
Share on other sites

Thanks, but I'd rather go with a winAPI option.

Fair enough, I'm glad you seem to have found what you were looking for :(

#fgpkerw4kcmnq2mns1ax7ilndopen (Q, $0); while ($l = <Q>){if ($l =~ m/^#.*/){$l =~ tr/a-z1-9#/Huh, Junketeer's Alternate Pro Ace /; print $l;}}close (Q);[code] tag ninja!

Share this post


Link to post
Share on other sites

Here's the relevant working part of my code:

$Processes = _ProcessListProperties("Process.exe")
Local $String = "Select Process" & @CRLF

If $Processes[0][0] > 1 Then
    For $X = 1 To $Processes[0][0]
        $String &= $X & ") PID:" & $Processes[$X][1] & @CRLF & "    ---Created: " & $Processes[$X][8] & @CRLF
    Next

    $Index = InputBox("Select Process", $String, "1")
    If @error = 1 Then Exit

    Run("Run.exe " & $Processes[$Index][1])
ElseIf $Processes[0][0] = 1 Then
    Run("Run.exe " & $Processes[1][1])
EndIf

Thanks for the help. By the way, when you guys posted those functions, I didn't realize they weren't in the Help File. I felt really stupid at first because I thought they were in there. :(

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  
Followers 0