darkjohn20 Posted March 25, 2010 Posted March 25, 2010 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.
Fulano Posted March 25, 2010 Posted March 25, 2010 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!
darkjohn20 Posted March 25, 2010 Author Posted March 25, 2010 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!
Yashied Posted March 25, 2010 Posted March 25, 2010 Look at _WinAPI_GetProcessCreationTime() from WinAPIEx.au3. My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More...
PsaltyDS Posted March 25, 2010 Posted March 25, 2010 (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 March 25, 2010 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
darkjohn20 Posted March 25, 2010 Author Posted March 25, 2010 Wow...How did I not see either of these....Will take a look. Thanks!
Fulano Posted March 25, 2010 Posted March 25, 2010 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!
darkjohn20 Posted March 25, 2010 Author Posted March 25, 2010 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.
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