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

CinnamonDonkey CinnamonDonkey at googlemail.com
Fri May 15 05:24:58 EDT 2009


Thanx for the response Tim! :-) Great site!

 > I'm genuinely surprised to hear you say that...

Early morning frustration... I appologise to all... you are totally
right. Thank you to all for the responses.

The sysinternal "Handle" tool that you made reference to earlier is
definately a working solution with minimal effort and I could indeed
use this to solve the problem.

I'd very much like to understand how such a problem could be solved
programatically though even if it means using some "underdocumented
and messy low-level NT APIs". Whilst taking the simplest approach is
the quickest to an end solution... it's also the least educational.
I'm as interested in how file locking works as I am in solving the
problem.

 > "you're perhaps adding to the not-helpfulness here..."

Again, a valid point and a lesson to be learned... I should actually
read the links I post before posting them! (I actually posted them so
that I could later read them at work).

Yes, this thread is specifically about who has the *lock* on a file.

Thanx TJG for the reality check ;-)

Shaun



On 15 May, 08:50, Tim Golden <m... at timgolden.me.uk> wrote:
> 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.h...
>
> >    http://timgolden.me.uk/python/win32_how_do_i/get-the-owner-of-a-file....
>
> 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