Jump to content
Sign in to follow this  
Fainth

Workingdir from a PID?

Recommended Posts

Fainth

Hey, i know this can be done in liux by a cmdline, but is there any way to determine the workingdir of a process, by PID or something? I need to find the source of a process that may or may not exist. Problem the Process is named all the same but could be startet from different directories.

My current solution is to check all possible sources for a lock.txt which is written when the process is startet. But there might be a more 'nice' method of checking this out.

Share this post


Link to post
Share on other sites
Ascend4nt

Check out my Process Functions UDFs (in my signature) for a way to get the Current directory using API calls. There's probably also a way to do with WMI calls.

(function name: _ProcessUDGetStrings())

Share this post


Link to post
Share on other sites
Fainth

Thank you for the lead, will check it out, and see if i can work with it :mellow:

Share this post


Link to post
Share on other sites
Fainth

Func checkpath($processname)
    $currentpath = ''
    $processhandle = _processopen($processname,0x0400)
    $processinfo = _ProcessGetPathname($processhandle)
    If Not @error Then $currentpath = $processinfo
    __PFCloseHandle($processhandle)
    If $currentpath = '' Then Return 0
EndFunc   ;==>checkpath

Yay! thnx mate :mellow:

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.