Find Out Which Program Has Locked A File

Print Page

How many times have you seen one of these Windows error messages when trying to delete or move a file?
Locked File in Windows

Normally, when a file a folder is locked by a process, the “File In Use” dialog would show the name of the process. You simply close the program and you’re good to go; however, there are cases where the name of the process is not shown. In such cases, the challenge is to find the program, process or user that has the file open.

In this post we are going to look at two such solutions to help us in identifying the process that has locked a file:
1. Build-in command-line solution: Openfiles.exe
2. Software solution: Unlocker

Unlock files and folders using Openfiles.exe

Openfiles.exe is a console tool that that has been part of Windows since 2000. Using Openfiles we can get a list of files that are open from local or shared folders.

Before we can start using the tool, we have to enable tracking of local file handles by enabling the system global flag ‘maintain objects list.’ To do so, run the following command in an Administrator PowerShell or Command Prompt window:

openfiles /local on

This will give you a confirmation as “SUCCESS: The system global flag ‘maintain objects list’ is enabled. This will take effect after the system is restarted.” Restart Windows for the change to take effect.

After restart, type in the following in an administrator console:

openfiles

This will give you a list of ID, process name, and files that are open locally or remotely via local share points.

To find which program has a file opened, we need to filter the result using the file name as paramater. This can be done like this:

openfiles | findstr /i just

The above command lists all open files that contain the word “just” in the file name.

In our example, it would show Word 2016 is currently having the lock over the file “Just another document.docx”. Once you have the filename, simply close the file and you can move on with the task you were doing.

Similarly, we can disconnect files and folders that have been remotely opened via a shared folder:

OPENFILES /Disconnect /OP "C:\My Documents\Just another document.docx" /ID 1234

That’s it. Now let’s look at a software solution using a free utility.

Unlock files and folders using Unlocker

Unlocker is a Windows Explorer extension that allows you to quickly right-click on a file and quickly to unlock it. Along with files, it can also unlock folders, DLLs, and delete index.dat files without having to reboot your Computer.

To use Unlocker, you just need to right-click on a file that’s locked and select “Unlocker” from the context menu. This will open Unlocker.

Next, select an action from the drop-down menu and click the “Unlock All” button. That’s all.

Unlocker is certainly a useful utility to have in your arsenal during those unexpectant times when one of those annoying Windows error messages appear.

Unlocker works on both 32-bit and 64-bit editions of all Windows versions. It’s available as an installer and portable version.

Download: Unlocker