Sign in to follow this  
Followers 0
gil900

Need help about how to get process description

3 posts in this topic

Hello,

below is my modified function to _ProcessListProperties() from >here

#include <Array.au3>; Only for _ArrayDisplay()
#AutoIt3Wrapper_Run_AU3Check=n

Global $oMyError = ObjEvent("AutoIt.Error","MyErrFunc"), $f_COMError = False


Global $avRET, $iPID

; Demonstrate listing all processes
$avRET = _ProcessListProperties()
_ArrayDisplay($avRET, "All Processes")
; This will return a list of processes that have path and without system username






Func _ProcessListProperties()
    Local $sUserName, $sMsg, $sUserDomain, $avProcs, $dtmDate
    Local $avProcs[1][3]
    ; Connect to WMI and get process objects
    $oWMI = ObjGet("winmgmts:{impersonationLevel=impersonate,authenticationLevel=pktPrivacy, (Debug)}!\\.\root\cimv2")
    If IsObj($oWMI) Then
        $colProcs = $oWMI.ExecQuery("select * from win32_process")
        If IsObj($colProcs) Then
            ; Return for no matches
            If $colProcs.count = 0 Then Return $avProcs
            ; For each process...
            For $oProc In $colProcs
                If $oProc.GetOwner($sUserName, $sUserDomain) = 0 And $oProc.ExecutablePath <> Null Then
                    $avProcs = _ArrayAdd2DAdd($avProcs,$oProc.name&"|"&$oProc.ExecutablePath)
                EndIf
            Next
            $avProcs[0][0] = UBound($avProcs) - 1
        Else
            SetError(2); Error getting process collection from WMI
        EndIf
        ; release the collection object
        $colProcs = 0
    EndIf
    Return $avProcs
EndFunc  ;==>_ProcessListProperties



; This is my custom error handler
Func MyErrFunc()
    Local $HexNumber=hex($oMyError.number,8)
    Msgbox(0,"","We intercepted a COM Error !" & @CRLF & _
                "Number is: " & $HexNumber & @CRLF & _
                "WinDescription is: " & $oMyError.windescription & @CRLF & _
                "Source is: " & $oMyError.source & @CRLF & _
                "ScriptLine is: " & $oMyError.scriptline)
   $f_COMError = True; something to check for when this function returns
Endfunc



Func _ArrayAdd2DAdd($aArray,$AddKey,$SplitVar = "|")
    Local $MaxArray = UBound($aArray)-1 , $Dimensions = UBound($aArray,2) , $Output = $aArray , $aAddKey
    ReDim $aArray[$MaxArray+2][$Dimensions]
    $aAddKey = StringSplit($AddKey,$SplitVar,1)
    $MaxArray = $MaxArray+1
    For $a = 1 To $aAddKey[0]
        $aArray[$MaxArray][$a-1] = $aAddKey[$a]
        If $a = $Dimensions Then ExitLoop
    Next
    Return $aArray
EndFunc

Now i want that this function will show the process description in Col 2 in the Array.

When i say "description" i mean to the description you see in windows task manager like in this example:

sYkcYv9.png

 
How can I do this?
Thanks for helpers!

 

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

$avProcs = _ArrayAdd2DAdd($avProcs,$oProc.name&"|"&$oProc.ExecutablePath & "|" & FileGetVersion($oProc.ExecutablePath, "FileDescription") )

There is no other way?

I thought about the idea but I do not like the idea .. but according to my test, it does not cause to the code to run slower ..

So i not supposed to care about it.. I'm just glad that the script is not human

Edited by gil900

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