Pfad von einen process heruasfinden?

  • Hallo, ich habe ein Problem. Ich will Pfad von einen Process herausbekommen.
    Ich habe bei der suche nur das hier gefunden. Hab Beiträge durchgelesen und da steht das es unter Vista nicht funktioniert, und ich habe leider Vista. Abgesehn davon weiß ich nicht genau wie ich es benutzen soll.
    Hat jemand eine Lösung?


    mfg
    Igrom4nru

    Einmal editiert, zuletzt von igromanru (27. Juli 2009 um 11:00)

    • Offizieller Beitrag

    Schau dir mal das 2. Script von AspirinJunkie an das funzt auch meisten bei Vista. Du mußt der Funktion nur die PID als Parameter übergeben .

  • Wenn ich richtig verstanden hab, dann so?

    [autoit]

    #include <_GetProcessPath.au3>
    $PID = ProcessExists("xxx.exe")
    $xy = _GetProcessPath($PID)
    MsgBox(0,"pfad",$xy)

    [/autoit]

    EDIT:
    _GetProcessPath.au3 ist:

    [autoit]

    Global $oWMI = ObjGet("winmgmts:\\localhost\root\CIMV2")

    [/autoit][autoit][/autoit][autoit]

    Func _GetProcessPath($hPID)
    For $o In $oWMI.ExecQuery("SELECT ExecutablePath FROM Win32_Process WHERE ProcessID=" & $hPID, "WQL", 48)
    Return $o.ExecutablePath
    Next
    EndFunc

    [/autoit]


    Hab es in den include ordner reingemacht.

    Einmal editiert, zuletzt von igromanru (27. Juli 2009 um 11:11)

  • Danke, also mit dem _GetProcessPath hat es geklappt, das andere hab ich noch nicht ausprobiert.

  • Bin im Urlaub und kann das nicht testen!

    Quelle von hier :

    Spoiler anzeigen

    $list = ProcessList("SvcHost.exe")
    for $i = 1 to $list[0][0]
    $pid = $list[$i][1]
    Local $hProc = DllCall("kernel32.dll", "int", "OpenProcess", "int", 0x0410, "int", False, "int", $pid)
    If $hProc[0] Then
    Local $stHMod = DllStructCreate("int hMod")
    Local $stCB = DllStructCreate("dword cbNeeded")
    Local $resEnum = DllCall("psapi.dll", "int", "EnumProcessModules", "int", $hProc[0], "ptr", DllStructGetPtr($stHMod), "dword", DllStructGetSize($stHMod), "ptr", DllStructGetPtr($stCB, 1))
    If $resEnum[0] Then
    Local $resPath = DllCall("psapi.dll", "int", "GetModuleFileNameEx", "int", $hProc[0], "int", DllStructGetData($stHMod, 1), "str", "", "dword", 32768)
    MsgBox(0, "PID 2 Path", "" & $Pid & " = " & $resPath[3])
    EndIf
    $stHMod = 0
    $stCB = 0
    DllCall("kernel32.dll", 'int', 'CloseHandle', 'int', $hProc[0])
    EndIf
    Next

    Grüsse aus Fethiye ;)

    UEZ

    Auch am Arsch geht ein Weg vorbei...

    ¯\_(ツ)_/¯

  • Also ich habe Vista und bei mir funktioniert folgendes problemlos:

    Spoiler anzeigen
    [autoit]

    #RequireAdmin

    [/autoit] [autoit][/autoit] [autoit]

    Global $hPsAPI = DllOpen("Psapi.dll")
    Global $hKernel = DllOpen("Kernel32.dll")

    [/autoit] [autoit][/autoit] [autoit]

    MsgBox(0,"", "Explorer:" & @CRLF & _ProcessGetPath("Explorer.exe"))

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _ProcessGetPath($hPID)
    If IsString($hPID) Then $hPID = ProcessExists($hPID)
    If $hPID = 0 Then Return SetError(1,0,'')
    Local $sPath = DllStructCreate("char[1000]")
    Local $hProcess = DllCall($hKernel, "int", "OpenProcess", "dword", 0x0400 + 0x0010, "int", 0, "dword", $hPID)
    DllCall($hPsAPI, "long", "GetModuleFileNameEx", "long", $hProcess[0], "int", 0, "ptr", DllStructGetPtr($sPath), "long", DllStructGetSize($sPath))
    DllCall($hKernel, "int", "CloseHandle", "hwnd", $hProcess[0])
    Return DllStructGetData($sPath, 1)
    EndFunc

    [/autoit]


    Hast du auch an das @RequireAdmin gedacht?
    Die Funktion ist nämlich deutlich schneller als die WMI-Lösung.