How To Find which process is locking your file in Windows

Windows comes with various annoyances and one of the biggest and most frequent ones is when you’re trying to delete a file and you get a message telling you that a file is in use and cannot be deleted.

The quickest fix for this issue is to find which process is locking your file in Windows – once you know it, you can terminate it and you’ll be able to delete, move, or rename that file.

How to find which process is locking your file in Windows

There are some party tools that can help you unlock a file, but there’s really no need because Windows already has a built-in tool you can use and it’s called OpenFiles.

OpenFiles works, but there is one problem. By default, it only tracks the files opened by remote users via local shared folders which isn’t helpful unless you actually have local shared points.

For the tool to track local opened files, we’ll need to enable the “maintain objects list” system global flag via Command Prompt.

find which process is locking your file in Windows

To begin with, open an elevated Command Prompt. To do this by click on the Start button, type “cmd” without the quote marks, right-click on the first result and select “Run as administrator”. Then, type the command below and hit enter:

OpenFiles /local on

Now you just need to restart your PC.

Once your computer reboots, it’s time to use OpenFiles. Open an elevated Command Prompt again and run the command below:

OpenFiles > %userprofile%\desktop\filelist.log

Once rebooted, open an elevated Command Prompt window again. All the commands below will get you the list of open files, but it’s a long list so you can export it to a file:

OpenFiles > %userprofile%\desktop\filelist.log

Or you can save it to the clipboard and paste it later in a text file:

OpenFiles | Clip

Or as a LIST or CSV file:

OpenFiles /Query /FO CSV

However, what we’re most interested in is to find the process that’s locking the file. You can do that using this command:

OpenFiles | FindStr /i document

Now you can either close the related application or end the process via Task Manager.

You can also find which process is locking your file in Windows using the Resource Monitor.

Open the Task Manager, go to the Performance tab and click on “Open Resource Monitor”.

On the Resource Monitor window, go to the CPU tab and in the Associated Handles section enter the file name in the search box. A list of associated processes will be displayed shortly.

Connect with us on FacebookTwitter, and Google+.