Re: (Winows) Finding out which process has locked a file.

2009-05-13 Thread Dave Angel



CinnamonDonkey wrote:

Hi all,

Does anyone know how I can programatically find out which process
(resolved to human friendly string, i.e. executable) has a lock on a
file.

I have a script running which occassionally fails because it is trying
to delete a file in use by another process. When this happens I want
it to log which process has the lock.

Since it tends to happen when I am never near the computer to catch
it! :(

Cheers,
Shaun


  
This may depend on what version of Windows you're using, as the API's 
changed in Windows 2000, and again in XP SP2, and probably again in Vista.


I don't know an API for what you want, but filemon, from 
http://technet.microsoft.com/en-us/sysinternals/bb896642.aspx

can build a log of file activity, which you can examine later.


If you do find an API that works on XP and better, please let us know.  
Even if you only know a function name, I'd be willing to play with it 
some, to see what it might do.  I'd like to find out, and would share 
what I did figure out.



--
http://mail.python.org/mailman/listinfo/python-list


Re: (Winows) Finding out which process has locked a file.

2009-05-13 Thread Tim Golden

CinnamonDonkey wrote:

Hi all,

Does anyone know how I can programatically find out which process
(resolved to human friendly string, i.e. executable) has a lock on a
file.

I have a script running which occassionally fails because it is trying
to delete a file in use by another process. When this happens I want
it to log which process has the lock.

Since it tends to happen when I am never near the computer to catch
it! :(



Usual place to look for these things is sysinternals (now part of
Microsoft). In particular, the handle util:

 http://technet.microsoft.com/en-us/sysinternals/bb896655.aspx

To get the same programatically you have to delve quite deep
into the NT low-level API. Not tried it myself.

TJG
--
http://mail.python.org/mailman/listinfo/python-list


Re: (Winows) Finding out which process has locked a file.

2009-05-13 Thread Emile van Sebille

On 5/13/2009 2:20 AM CinnamonDonkey said...

Hi all,

Does anyone know how I can programatically find out which process
(resolved to human friendly string, i.e. executable) has a lock on a
file.

I have a script running which occassionally fails because it is trying
to delete a file in use by another process. When this happens I want
it to log which process has the lock.



You might take a look at http://ccollomb.free.fr/unlocker/ -- I've not 
used the command line options although they are available...


Emile


--
http://mail.python.org/mailman/listinfo/python-list


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

2009-05-13 Thread CinnamonDonkey
Hi all,

Does anyone know how I can programatically find out which process
(resolved to human friendly string, i.e. executable) has a lock on a
file.

I have a script running which occassionally fails because it is trying
to delete a file in use by another process. When this happens I want
it to log which process has the lock.

Since it tends to happen when I am never near the computer to catch
it! :(

Cheers,
Shaun
-- 
http://mail.python.org/mailman/listinfo/python-list