xManh Posted November 23, 2006 Share Posted November 23, 2006 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 Link to comment Share on other sites More sharing options...
xcal Posted November 23, 2006 Share Posted November 23, 2006 (edited) 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 November 23, 2006 by xcal mLipok 1 How To Ask Questions The Smart Way Link to comment Share on other sites More sharing options...
theguy0000 Posted November 23, 2006 Share Posted November 23, 2006 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 Link to comment Share on other sites More sharing options...
xManh Posted November 23, 2006 Author Share Posted November 23, 2006 Yeah, that's what i'm seeking for, thankyou very much! Link to comment Share on other sites More sharing options...
Valuater Posted November 23, 2006 Share Posted November 23, 2006 might want to error check after this line $pid = ProcessExists($exe) object errors can crash the program 8) Link to comment Share on other sites More sharing options...
xManh Posted November 23, 2006 Author Share Posted November 23, 2006 Nice advice, thanks! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now