When you see the error “The process cannot access the file because it is being used by another process,” you can use several built-in or free tools to find out which process is locking the file or folder.
Using Resource Monitor
Resource Monitor is built into Windows:
- Press Win + R, type resmon, and press Enter. This will open Resource Monitor.
- Go to the CPU tab.
- In the Associated Handles section, use the search box to enter part of the file or folder name.
- The results will show which processes are using the file. Check the Image and PID columns to identify the process.
- You can right-click the process and select End Process if necessary (be cautious when ending processes).
Using Process Explorer
Process Explorer is a free tool from Microsoft Sysinternals:
- Download and run Process Explorer as administrator. You can acquire Process Explorer using the following WingGet command:
Winget install Microsoft.Sysinternals.ProcessExplorer
- In Process Explorer, Press Ctrl + F or go to Find > Find Handle or DLL.
- Type part of the file or folder name and click Search.
- The tool will list all processes currently using the file. Click an entry to highlight the process in the main window.
- You can right-click the handle and select Close Handle to release the file (use with caution).
Using Command Line Tools
- openfiles: Run openfiles /query in Command Prompt (may require enabling with openfiles /local on and a restart). This shows which files are open and by which process. You’d have to enable the local on option before the file got locked of course.
- handle.exe: Download from Sysinternals. You can acquire Handle.exe with the following WinGet command:
winget install Microsoft.Sysinternals.Handle
- Run handle.exe <filename> to list processes using the file.