[python-win32] Finding the PID of open files

Andrew Ziem ahz001 at gmail.com
Fri Jun 26 06:02:34 CEST 2009


I'm looking for a painless way to find the process ID that locks a
file in Python for my open source project with these specs:

* Runs as non-administrator
* Covers processes/files owned by the current user (I don't care about
service accounts, etc.)
* Installs as administrator or not (I don't care)

Tim Golden's code[1] is close, but it lists fewer files than Mark
Russinovich's handle.exe: for example, index.dat is not listed.

I am not a Win32 guru.  ;)  Any suggestions?


Andrew

[1] Tim's code:
http://code.google.com/p/winsys/source/browse/trunk/random/file_handles.py
My tweaks: http://pastebin.com/f2210f2b


More information about the python-win32 mailing list