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

Tim Golden mail at timgolden.me.uk
Fri May 15 17:54:58 CEST 2009


CinnamonDonkey wrote:
> 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.

Well it's big of you to apologise. In return, I've managed to knock
up an example of determining locked file owners. But it is a tad
messy. I'll try to work it up into an annotated example, but for
now it's on pastebin:

  http://python.pastebin.com/m7b4e420a

It manages to mix pywin32, ctypes and wmi over COM via my WMI module.
I may have missed some useful shortcuts but I think it does enough
to illustrate what's going on. It's mostly a translation of a
posting which I'll try to link to when I can find it again, to
give credit where it's due.


> Thanx TJG for the reality check ;-)

Well I hope the above is helpful.

TJG



More information about the Python-list mailing list