Jump to content
Sign in to follow this  
xManh

How to get the path where a process executed from?

Recommended Posts

Is it possible to get path of a process, for example, getting path of explorer.exe returns C:\Windows\explorer.exe

Thanks for any comment

Share this post


Link to post
Share on other sites

Originally pilfered from gafrost, modified slightly by me.

$dir = _GetPIDPath('your.exe')

MsgBox(0, '', $dir)

Func _GetPIDPath($exe)
    $pid = ProcessExists($exe)
    $objWMIService = ObjGet('winmgmts:\\localhost\root\CIMV2')
    $colItems = $objWMIService.ExecQuery ('SELECT * FROM Win32_Process WHERE ProcessId = ' & $pid, 'WQL', 0x10 + 0x20)
    For $objItem In $colItems
        If $objItem.ExecutablePath Then Return $objItem.ExecutablePath
    Next
EndFunc

edit - because I edit everything at least once.

Edited by xcal

Share this post


Link to post
Share on other sites

Originally pilfered from gafrost, modified slightly by me.

$dir = _GetPIDPath('your.exe')

MsgBox(0, '', $dir)

Func _GetPIDPath($exe)
    $pid = ProcessExists($exe)
    $objWMIService = ObjGet('winmgmts:\\localhost\root\CIMV2')
    $colItems = $objWMIService.ExecQuery ('SELECT * FROM Win32_Process WHERE ProcessId = ' & $pid, 'WQL', 0x10 + 0x20)
    For $objItem In $colItems
        If $objItem.ExecutablePath Then Return $objItem.ExecutablePath
    Next
EndFunc

edit - because I edit everything at least once.

that's cool....

The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

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  

×
×
  • Create New...