Jump to content
Sign in to follow this  
gracea

Help: How to get wmi executable path of each process list...?

Recommended Posts

gracea

Help please..

Already read a lot of autoit wmi samples and tried editing. Cant find exact samples for what i need. I am still fine at this point but my logic is not like yours and that was the problem.

I wanted to stick to the current script format. List the process name line by line to txt file. But this time with executable path for each process. from the current script... creating $ProcessExecutablePathh is my problem.

Whenever i started figuring out how to do it i just halted. Despite there is a similar solutions from the link but it has a lot of code on it and - there is gui command - and there is column commands - just made me confused a lot.

I got the long comment line from here:

http://stackoverflow.com/questions/17067705/how-to-get-all-tasks-and-services-running-in-the-context-of-a-specific-user-unde

The link sample was great but i do not need GUI (for now).

$FileNamee = @ScriptName&".txt"
Sleep (500)
Local $ProcessNamee = ProcessList()
For $i = 1 To $ProcessNamee[0][0]
    If $ProcessNamee[$i][0] <> "" Then

#cs
    $oWMI = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $sComputer & "\root\cimv2")
    If IsObj($oWMI) Then
        $colProcs = $oWMI.ExecQuery("select * from win32_process")
        If IsObj($colProcs) Then
            For $oProc In $colProcs
                $sObjName = ObjName($oProc, 1)
                If @error Then ContinueLoop; Skip if process no longer exists
                    For $n = 1 To $avProcs[0][0]
                        If $avProcs[$n][1] = $oProc.ProcessId Then
                            $avProcs[$n][5] = $oProc.ExecutablePath
                        EndIf
                EndIf
        EndIf   
    EndIf
#ce

        FileWriteLine($FileNamee, "  " & $ProcessNamee[$i][0] & $ProcessExecutablePathh & @CRLF)
        Sleep (100)
    EndIf
Next
Sleep (500)
MsgBox(262144,"","COMPLETED.")
Exit

Number listing addition would be a sweet plus.


:P " Loved It ! " :wub:

Share this post


Link to post
Share on other sites
jguinch

Sorry, I don't understand what you really wants to do...

You want to get the full path of each process listed in the ProcessList array ?

Maybe something like this :

$aProcess = ProcessList()
$oWMI = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & @ComputerName & "\root\cimv2")

If IsObj($oWMI) Then
    $colProcs = $oWMI.ExecQuery("select * from win32_process")
    If IsObj($colProcs) Then
        For $oProc In $colProcs
            $iPid = $oProc.ProcessId
            
            
            For $i = 1 To $aProcess[0][0]
                If $aProcess[$i][1] = $iPid Then
                    ConsoleWrite($aProcess[$i][0] & @TAB & $aProcess[$i][1] & @TAB & $oProc.ExecutablePath & @CRLF)
                    ExitLoop
                EndIf
            Next
        Next
    EndIf   
EndIf

Share this post


Link to post
Share on other sites
gracea

Hey jguinch.

Thank you for your reply. Your script is working just what i wanted. But i am still having a problem understanding it. I am trying to apply it to other script. My post was answered.


:P " Loved It ! " :wub:

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  

×