[python-win32] Re: Getting path+executable associated with a process

Roger Upole rwupole at msn.com
Wed Feb 9 21:23:28 CET 2005


These functions in win32process should be able to get that for you:
OpenProcess, EnumProcessModules and GetModuleFileNameEx
The executable will be the first module returned from EnumProcessModules.
       Roger


Gabriel Reis wrote:
> Hi,
> 
> I want to get the executable filename and its path from a process.
> Imagine that I have an application installed in two different
> directories. The rule is: the user can't run an instance of this
> application if another instance, from the *same* directory, is already
> running.
> 
> I've read PyWin32 documentation and browsed this maillist's history
> and I couldn't find anything specifically. With the method
> MakeCounterPath I can get information (items) such as Memory, Process
> ID or % CPU... so I am wondering if I can get the executable path too,
> once I have the PID.
> 
> Best regards,
> 
> Gabriel Reis


More information about the Python-win32 mailing list