Sign in to follow this  
Followers 0
GaryFrost

Process Info using objects and wmi

2 posts in this topic

#1 ·  Posted (edited)

#include <Array.au3>

$colItems = ""
$strComputer = "localhost"

$a_ProcessInfo = _GetProcessInfo($strComputer)
For $i = 1 To $a_ProcessInfo[0]
    $process = StringSplit($a_ProcessInfo[$i], "|")
    MsgBox(0, "Process Info", "Name: " & $process[1] & @CRLF & _
            "PID: " & $process[2] & @CRLF & _
            "Memory: " & $process[3])
Next

Func _GetProcessInfo($strComputer)
    Dim $a_items[1]
    Const $wbemFlagReturnImmediately = 0x10
    Const $wbemFlagForwardOnly = 0x20
    
    Dim $a_items[1], $objWMIService, $colItems = ""
    $objWMIService = ObjGet ("winmgmts:\\" & $strComputer & "\root\CIMV2")
    $colItems = $objWMIService.ExecQuery ("SELECT Name,IDProcess,WorkingSet FROM Win32_PerfFormattedData_PerfProc_Process", "WQL", _
            $wbemFlagReturnImmediately + $wbemFlagForwardOnly)
    If IsObj ($colItems) Then
        For $objItem In $colItems
            If $objItem.Name <> "_Total" Then
                ReDim $a_items[UBound($a_items) + 1]
                $a_items[UBound($a_items) - 1] = $objItem.Name & "|" & $objItem.IDProcess & "|" & $objItem.WorkingSet
                $a_items[0] = $a_items[0] + 1
            EndIf
        Next
    EndIf
    _ArraySort($a_items)
    Return $a_items
EndFunc  ;==>_GetProcessInfo

Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites



a user in support forum asked for pids....

this is perfect

thx

8)


NEWHeader1.png

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