Key Points
- If a file is in use, you check which process is using it from Sysinternal’s Process Explorer. Launch the app, drag and drop the Gunshot icon onto the window of the file or folder, and it will highlight the associated process. Right-click the process and kill it to release the file.
- The Resource Monitor can also be used to release locked files. Open the Resource Monitor, switch to the CPU tab, expand “Associated Handles“, search for the file, right-click the process, and kill it.
While attempting to move, cut, or delete a file or folder, you may encounter an error message preventing you from performing the task. It happens when the system locks a file or folder and does not allow any operations to be performed, and the most common cause for this is that the file is actively in use by another program or a process.
Sometimes, the popup dialog box prompts the user to close a certain process or an application before they are allowed to perform the actions. At other times, no such intimation is given, except that we are told by the Windows OS that it is being used, and we have to figure out which app or process is using it.
You may come across one of the following error messages when a file or folder is locked:
- The action can’t be completed because the file is open in another program
- This file is in use by another program or user
- The source or destination file may be in use
- Cannot delete file: Access is denied
- There has been a sharing violation
- Make sure the disk is not full or write-protected and that the file is not currently in use
Note that none of these prompts tells you which process or app is locking the item and preventing you from completing the task. So how do you tell which process has the file open, or which app is using it?
There are multiple ways of checking which process or app is using the file you want to modify. Additionally, you can also end those processes to release the files and perform your tasks without hindrances and prompts.
Table of Contents
Identify and release locked file with Sysinternals Process Explorer
Process Explorer is a portable utility by Sysinternals whose primary function is to provide information on processes and everything there is to know about them. It can also be used to manage the processes.
Using Process Explorer, you can check which process is locking a file or folder, and then also end the process which in turn will release the file.
Apply the following steps to download and use Sysinternals Process Explorer to identify which process is locking a file:
-
Open the Sysinternals Process Explorer page and download the tool.
-
Right-click the downloaded package and click “Extract all.”
-
Click Extract in the extraction wizard.
-
Right-click the “procexp64.exe” file and then click “Run as administrator.”
Note: If you have a 32-bit operating system, then run the proexp.exe file as an admin instead.
-
Now that Process Explore is running, there are two ways to find and close the process locking the file or folder:
-
From searching
-
In Process Explorer, click Find in the ribbon menu, and then click “Find Handle or DLL.”
-
Enter the file or folder name that is locked and then click Search.
-
Click on the associated process using the file in the Search window.
This will automatically highlight the process in the Process Explorer window as well.
-
Right-click on the process in the Process Explorer window and click “Kill process tree.”
-
-
Using the gunshot icon
-
Click and hold the gunshot icon in the top menu, and drop it over the locked file or folder.
The associated process locking the file will now be highlighted in the Process Explorer.
-
Right-click on the highlighted process and click “Kill process tree.”
-
-
Process Explorer is a quick and handy method to identify which file(s) are being used by which processes, so you can free them up and perform your more important tasks at hand first.
That being said, caution is advised while performing these steps, since killing the system-critical processes can affect how the OS operates, or worse, damage the files permanently if they are interrupted in the middle of another task.
Check and release locked file using Resource Monitor
Resource Monitor is a Windows-native utility that can be used to monitor the different system resources, including the CPU, the GPU, the RAM, disk, and network bandwidth. It can also be used to display and manage the processes using certain files or folders, using which, you can release them by ending the process using them.
Use the following steps to release a file or a folder using the Resource Monitor so you can continue to perform your own action:
-
Press the Windows key + R to open the Run Command box.
-
Type in “resmon” and press Enter to launch the Resource Monitor.
-
Switch to the CPU tab and then click “Associated Handles” to expand it.
-
Search for the name of the locked file in the Associated Handles section.
This will show a list of the processes using that particular file.
-
Right-click on the process using the file and then click “End process.”
Identify process locking the file using command line
If you are a fan of the command line, then you can use the Command Prompt to check which process is using the file. This can be achieved using Microsoft’s Handle command-line utility, but note that it will only inform you about the process. You cannot kill the process using this tool.
You can however use the Task Manager or the “kill” command to end the process.
Here are the steps to download and use Handle to check which process is using a locked file:
-
Go to the Handle page and download the tool.
-
Extract the downloaded package.
-
Now press the Windows Key + R to open the Run Command box.
-
Type in “cmd” and press CTRL + Shift + Enter to run an elevated Command Prompt.
-
Now use the “cd” command to change the current directory to the extracted Handle folder.
cd /d [PathToHandleFolder]
-
Now, run the following command while providing the complete path to the locked file (including file extension) to check which process(es) is using it:
handle.exe -a -u "[CompletePathToLockedFile.Extension]"
As you can see in the example above, I provided the complete path of the file, along with its correct extension, inside inverted commas. This is because the path had spaces between some words, and for it to be Command Prompt-readable, it needs to be inside inverted commas.
After running the command, Handle returned the name of the process using the file, including other useful information, such as the process ID. You may now use this information to kill the process from the Task Manager, or using the Command Prompt.
Check and release locked files using third-party tools
Like Microsoft’s own utilities, there are also a plethora of third-party tools that offer similar functionality and can be used to find and release locked files. Many of these tools are freeware and safe to run on your Windows computers.
Here are a few third-party tools to identify and kill processes using certain files and folders:
Closing words
Coming across a file that you need to modify and finding that it is locked can be annoying, especially when you do not know where it is being used.
Usually, such issues can be resolved by restarting the computer, which unlocks the files and leaves it free for you to delete, edit, or move. However, one cannot always restart a PC when coming across such issues. In such instances, you can use the native Resource Monitor, the Process Explorer, or any number of third-party tools to check which process is using it, so it can be ended and the file can be freed.