Jump to content

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


 Share

Go to solution Solved by jguinch,

Recommended Posts

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:

Link to comment
Share on other sites

  • Solution

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
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...