views:

366

answers:

3

How do you go about querying running processes to find out what folders or files they have locked? (i.e. you go to eject a drive and you're told that it can't be ejected because it's in use)

I'd like to either get an "off the shelf" download, or write a .NET 3.5 app to do this (primarily a Windows question).

+8  A: 

Process Explorer will show you this. Ctrl-F will let you search for a file and list the process(es) that have that file open/locked. You can then close that handle using Process Explorer.

There's also a command line utility called oh.exe available for download. See here for more details

Brian Agnew
Process Expolorer is my tool of choice for this. It also allows you to close the handle.
Marnix van Valen
Good point re. the handle closing. I'd forgotten that. Answer amended
Brian Agnew
A: 

http://ccollomb.free.fr/unlocker/ (freeware) has a special UI for exactly this situation.

Rutger Nijlunsing
A: 

One of the first things I put on my Windows dev machines is WhoUses. It's nice because it's open source too.

marcc