Ever get that annoying “File in use” error when trying to delete something in Windows? It’s super frustrating, especially when you can’t figure out what’s holding it hostage. Here are a few ways to kick that file loose and finally delete it!
Method 1: Use Command Prompt to force delete the file
If you’re comfortable with the command line, this method can be quite effective for stubborn files.
- First, head to the location of the file you’re trying to delete in File Explorer.
- Click in the address bar at the top of File Explorer to highlight the file path, then copy it (
Ctrl + C
).
- Open the Start menu, type
cmd
, and then select “Run as administrator.” You’ll need administrator privileges for this to work.
- In the Command Prompt window, type
cd
followed by a space, then paste the file path you copied earlier (Ctrl + V
) and press Enter. This changes the directory to the location of your file.
- Next, open Task Manager (
Ctrl + Shift + Esc
). In the “Processes” tab, find “Windows Explorer,” right-click it, and select “End task.” This will temporarily close File Explorer.
Note: If you do not see the ‘End task’ option directly, click on File Explorer to expand it. Then right-click on ‘This PC - File Explorer’ and you should see the ‘End task’ option.
- Go back to the Command Prompt window and type
del "filename"
(replace “filename” with the actual name of your file, including the extension). Press Enter to force delete the file. Make sure to include the quotation marks.
- To restart File Explorer, press
Ctrl + Shift + Esc
again to open Task Manager. - Click “Run new task”, type
explorer.exe
, and hit Enter. This will bring File Explorer back.
Method 2: Identify the program using the file with Resource Monitor
Resource Monitor is a built-in tool that can pinpoint exactly which program is using your file.
- Open the Start menu, type
resource monitor
, and click “Resource Monitor” in the results.
- In Resource Monitor, go to the “CPU” tab and expand the “Associated Handles” section.
- Type the name of the file you want to delete into the search box. Resource Monitor will then display any processes currently using that file.
- To stop the processes, right-click each one and select “End task.” After ending the task, try deleting the file again.
Method 3: Unlock the file using Powertoys
Microsoft PowerToys is a fantastic free utility that includes a tool called “File Locksmith” designed specifically for this problem.
- Download PowerToys from the Microsoft Store.
- After installing, launch PowerToys and click on “File Locksmith” in the left-hand menu.
- Turn on the File Locksmith feature by clicking the toggle switch to the “On” position.
- Find the file you’re struggling to delete, right-click it, and choose “Unlock with File Locksmith”.
- File Locksmith will display the processes locking the file. You can directly end the program using the file by clicking on “End task.” Then, try to delete the file.
Method 4: Use the Process Explorer to unlock the file
Process Explorer, another tool from Microsoft, gives you even more control over running processes.
- Download Process Explorer from the Process Explorer download page. Download the tool as a zip file containing three .exe files.
- Extract the downloaded .zip file and run the .exe file that’s compatible with your system (32-bit or 64-bit).
- You’ll need to agree to the license terms. Once Process Explorer is running, click “Find” at the top, then “Find Handle or DLL” (or use the shortcut
Ctrl + Shift + F
).
- Type the name of the file you can’t delete and click “Search.” Process Explorer will show you any processes using that file.
- Find the process or application using the program, you can end it using the Task Manager. This should let you delete the file.
Method 5: End the process or application using Task Manager
Task Manager is your go-to for ending unruly processes.
- Open Task Manager by right-clicking the taskbar and selecting “Task Manager,” or by pressing
Ctrl + Shift + Esc
.
- Make sure you’re on the “Processes” tab (it should be selected by default).
- Look for the program associated with the file you want to delete. For example, if it’s a PDF, it might be open in Adobe Acrobat or your browser. Right-click the program and choose “End task”.
- Repeat for any other programs that might be using the file. Then, try deleting the file again.
Method 6: Change the process settings in File Explorer
Sometimes File Explorer itself can be the problem.
- Open File Explorer, click the three dots at the top (next to “View”), and select “Options.”
- In the Options dialog, go to the “View” tab. Uncheck the box that says “Launch folder windows in a separate process.”
- Click “Apply” and then try deleting the file again.
Method 7: Turn off the Preview pane in File Explorer
The Preview pane can sometimes lock files.
- In File Explorer, click the “View” tab at the top. Make sure the “Preview pane” option is not selected (disabled). If it’s highlighted, click it to turn it off.
- Now, try deleting the file again.
Method 8: Delete the file in Safe Mode
Safe Mode starts Windows with a minimal set of drivers and services, which can help if a background process is interfering.
- Press and hold the
Shift
key, then click “Restart” from the Start menu or sign-in screen. Keep holdingShift
until the Windows Recovery Environment appears. - In the Windows Recovery Environment, click on “Troubleshoot”, and then on “Advanced options”.
- On the Advanced Options screen, select “Startup Settings” and then click the “Restart” button.
- After your computer restarts, you’ll see a list of startup options. Press the number key corresponding to “Safe Mode” (usually 4). Let your PC boot up. Then go to the file and try deleting it.
Method 9: Identify the program manually and close it
This might sound obvious, but it’s the first thing you should try! You might have the file open in an application without realizing it.
Take a close look at your open programs. Have you closed the program with which you opened the file? Even if you’ve closed the file within the program, try closing the entire program itself.
Also, check for multiple instances of the same file. Look at the taskbar, and close any minimized windows that might be holding the file open. If you are unable to identify which application you used to open the file, or cannot identify it, close all open programs and then try to delete the file again.
Things to know
- Third-party tools like Unlocker and LockHunter can also help you unlock the file from the program using it so you can easily delete it.
- If you unlock the file but still can’t delete it, try restarting your computer and then trying again. This can clear any lingering processes.
- Handle is the command-line version of Process Explorer.
- Before force-closing anything, be sure it’s safe to do so. Ending the wrong process could cause data loss or system instability. It’s always a good idea to back up the file if you’re concerned.