Hallo,
Ihc wollte fragen ob es eine möglich keit gibt, nur durch ein Fenster oder Prozess herauszufinden, wo die exe des programms liegt.
ich hoffe ihr habt die frage verstanden und könnt mir helfen
Mfg BangerzZ
Hallo,
Ihc wollte fragen ob es eine möglich keit gibt, nur durch ein Fenster oder Prozess herauszufinden, wo die exe des programms liegt.
ich hoffe ihr habt die frage verstanden und könnt mir helfen
Mfg BangerzZ
ShellExecute("mspaint.exe")
$pid = ProcessExists("mspaint.exe")
$FilePath = _PidGetPath($pid)
MsgBox(0, "", $FilePath)
Func _PidGetPath($pid = "", $strComputer = 'localhost')
If $pid = "" Then $pid = WinGetProcess(WinGetTitle(""))
$wbemFlagReturnImmediately = 0x10
$wbemFlagForwardOnly = 0x20
$colItems = ""
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_Process WHERE ProcessId = " & $pid, "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly)
If IsObj($colItems) Then
For $objItem In $colItems
If $objItem.ExecutablePath Then Return $objItem.ExecutablePath
Next
EndIf
EndFunc ;==>_PidGetPath
Oder hiermit (ist glaub ich schneller als die WMI-Variante):
;===============================================================================
; Function Name: _GetPathByPID($PID=-1)
; Description:: Get full path of an running application by using PID
; Parameter(s): $PID - PID, if not set will used PID from active Window
; Requirement(s): #include <WinAPI.au3>
; Return Value(s): Success Full ApplicationPath
; Failure set @error 1 - process handle failed
; 2 - process image failed
; 3 - query dosdevice failed
; Author(s): BugFix ([email='bugfix@autoit.de'][/email])
;===============================================================================
Func _GetPathByPID($PID=-1)
If $PID = -1 Then $PID = WinGetProcess(WinGetTitle("[active]"))
$hProcess = _WinAPI_OpenProcess(0x00000400, True, $PID, True)
If Not $hProcess Then Return SetError(1,0,0)
Local $ret, $path, $DevicePath, $DeviceLetter, $strPath = DllStructCreate("char path[256]")
DllCall(@SystemDir & '\Psapi.dll', "uint64", "GetProcessImageFileNameA", _
"hwnd", $hProcess, "ptr", DllStructGetPtr($strPath), "int", 256)
If @error Then Return SetError(2,0,0)
$path = DllStructGetData($strPath, 'path')
$DevicePath = StringRegExp($path, "\\Device\\\w*", 1)
Local $lpTargetPath, $aDrive = DriveGetDrive("ALL")
For $i = 1 To UBound($aDrive) -1
$ret = DllCall("kernel32.dll", "long", "QueryDosDeviceA", "str", $aDrive[$i], "str", $lpTargetPath, "long", 256)
If @error Then Return SetError(3,0,0)
If $ret[2] = $DevicePath[0] Then
$DeviceLetter = $aDrive[$i]
ExitLoop
EndIf
Next
DllCall("kernel32.dll", "long", "CloseHandle", "long", $hProcess)
Return StringReplace($path, $DevicePath[0], StringUpper($DeviceLetter))
EndFunc ;==>_GetPathByPID
erstmal danke das macht es mir um einiges leichter
und was genau gibt das wieder? nur den phad oder mit der exe?
also c:/Programme oder c:/Programme/example.exe?
und was genau gibt das wieder? nur den phad oder mit der exe?
Das liegt doch auf der Hand, oder?
Zitat; Return Value(s): Success Full ApplicationPath