Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find out what processes have folder or file locked?

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).

like image 903
CodeMonkey1313 Avatar asked Jul 05 '09 17:07

CodeMonkey1313


People also ask

How do you find out which processes are locked up?

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.

Which processes have a file open?

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.

Who is locking this folder?

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.

How do you unlock a file used by another process?

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.


3 Answers

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

like image 136
Brian Agnew Avatar answered Oct 16 '22 19:10

Brian Agnew


LockHunter is a great context menu tool for Windows.

like image 5
CodeMonkey1313 Avatar answered Oct 16 '22 18:10

CodeMonkey1313


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

like image 2
marcc Avatar answered Oct 16 '22 18:10

marcc