(Windows) Finding out which process has locked a file.

Tim Golden mail at timgolden.me.uk
Fri May 15 03:50:37 EDT 2009


CinnamonDonkey wrote:
 > I have to say, this has got to be one of the
 > least helpful groups I am subscribed to.

I'm genuinely surprised to hear you say that, especially
about this thread to which you (who appear to be the OP)
have received several replies all pointing you towards
the sysinternals tools which are pretty much the de facto
standard for doing things of this type. They're not
API calls but they're a reasonable compromise between
doing some simple parsing of output and dealing with
some underdocumented and messy low-level NT APIs.

Granted there was one rather silly response but they
really are few and far between on this list I think.
(Or perhaps I just filter them out...)

> Some interesting links...
> 
>    http://support.microsoft.com/kb/218965
> 
>    http://timgolden.me.uk/python/win32_how_do_i/add-security-to-a-file.html#the-short-version
> 
>    http://timgolden.me.uk/python/win32_how_do_i/get-the-owner-of-a-file.html

Unforunately, you're perhaps adding to the not-helpfulness here
since none of those links (and I'm the author of two of them)
address the question. The original request doesn't want to
know what security is preventing you from accessing the file: it
wants to know who has a *lock* on the file, and as I pointed
out earlier, this is only accessible by some low-level API calls.

If I and others have misunderstood the original question, then
please come back and say so, but your original request seems
fairly clearly to point towards file locking and not to
security & ownership.


TJG



More information about the Python-list mailing list