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).
Microsoft/SysInternals Process Explorer - Go to Find > Find Handle or DLL. In the "Handle or DLL substring:" text box, type the path to the file (e.g. "C:\path\to\file. txt") and click "Search". All processes which have an open handle to that file should be listed.
The easiest way to check which process has a file open is to download the Sysinternals Process Explorer tool. Launch the tool and select Find Handle or DLL... then type in the name of the file and click Search, as shown below. The processes that have a handle to any file with the search text in it will be shown.
There are many third party free Tools to find out which processes are locking your file. 1 – Just download LockHunter and install it. 2 – Now, right click on the file and click on What's locking this file? option from the context menu and it will show you the locking processes.
Sometimes when you try to delete, rename or move a file in Windows, you may see a message that the file is busy/locked/used by another process. Usually the name of the program that keeps the file open is shown right in the File Explorer message window. To unlock the file, it is enough just to close the program.
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
LockHunter is a great context menu tool for Windows.
One of the first things I put on my Windows dev machines is WhoUses. It's nice because it's open source too.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With