How to Delete Locked and In-Use Files in Windows
In this article
You can delete a locked or in-use file in Windows by closing the program that holds it, using Task Manager to end the blocking process, or restarting the PC to release the handle. If the file still will not delete, use built-in tools like Resource Monitor or the Command Prompt, or schedule the deletion for the next reboot with a tool such as Process Explorer. The file is locked because Windows or another program has an open handle to it, so the fix is to find and release that handle rather than forcing the delete blindly.
What You'll Need
- A Windows PC with an administrator account (some steps require elevation).
- Task Manager, Resource Monitor, and Command Prompt, all built into Windows.
- Optional: Microsoft Sysinternals Process Explorer, a free official Microsoft tool, if you want to find the exact process holding a file handle.
- Optional: a third-party unlocker utility from a reputable vendor, only if the built-in methods fail.
Menu labels and wording can differ slightly between Windows versions, editions, and regions. The steps below refer to Windows 10 and Windows 11, where the built-in tools are essentially the same.
Step-by-Step
- Close the obvious program first. If you know which app has the file open (a document in Word, a video in a player, a log file in an editor), close it normally and try deleting the file again. Many locks disappear as soon as the owning app exits.
- Restart the PC. A restart releases almost every handle held by running programs and by Windows itself. After the restart, try the delete again before doing anything more aggressive. This alone fixes the majority of locked-file cases.
- Open Task Manager and end the blocking process. Press Ctrl+Shift+Esc, go to the Processes tab, find the app that likely owns the file, right-click it, and choose End task. Then try deleting the file. Be aware that ending a process discards unsaved work in that app.
- Use Resource Monitor to find the exact handle. Open Start, type Resource Monitor, and launch it. Go to the CPU tab and expand the Associated Handles section. Type the file name (or part of it) into the Search Handles box. The list shows which process is holding the file. Right-click that process and choose End Process, then delete the file.
- Try Command Prompt with elevated rights. Open Start, type cmd, right-click Command Prompt, and choose Run as administrator. Use the del command with the full path, for example: del "C:\Folder\file.ext". If the file is in use, this will still fail, but it confirms the lock is real and not a permissions problem. For a folder, use rmdir /s /q "C:\Folder".
- Schedule deletion at the next reboot. If the file is locked by Windows itself (common with system logs, update leftovers, or files in use by services), you can mark it for deletion on restart. The built-in way is to use the MoveFileEx API through a small script, but the simpler supported route is Process Explorer from Microsoft Sysinternals: open it as administrator, press Ctrl+F, search for the file name, right-click the handle, and choose Close Handle. Then delete the file normally. If the handle is held by a critical system process, Process Explorer will warn you; do not close handles for processes you do not recognise.
- Boot into Safe Mode as a last built-in resort. Open Settings > System > Recovery (Windows 11) or Settings > Update & Security > Recovery (Windows 10), choose Restart now under Advanced startup, then go to Troubleshoot > Advanced options > Startup Settings > Restart, and select Safe Mode. In Safe Mode, most third-party programs and services do not run, so the lock is usually gone. Delete the file, then restart normally.
- Check permissions if the error is Access Denied rather than a lock. Right-click the file, choose Properties > Security, and confirm your account has Full control. If not, click Edit, select your user, tick Full control, and apply. You may need to take ownership first via Advanced > Owner. Only do this for files you created or clearly own; changing ownership on system files can break Windows.
Common Mistakes
- Deleting system files. Files in C:\Windows, C:\Program Files, or under your user profile's AppData folder are often locked for good reason. Removing them can break Windows or an application. Confirm the file is not part of an installed program before forcing a delete.
- Ending critical processes. In Task Manager or Resource Monitor, ending processes like System, csrss.exe, winlogon.exe, or services.exe can crash or restart your PC. Only end processes you recognise as the app holding your file.
- Assuming every failure is a lock. "Access is denied" usually means permissions, not a lock. Check the Security tab before hunting for handles.
- Using random unlocker tools. Many free "file unlocker" utilities bundle adware or worse. Prefer Microsoft's own Process Explorer and built-in Windows tools.
- Forgetting to save work. Ending a process or restarting discards unsaved changes in open documents. Save everything you can before you start.
Tips
- Search Resource Monitor by partial file name; you do not need the full path.
- If a file keeps getting re-locked, the owning app may be restarting itself (common with sync clients and antivirus). Pause or exit that app from its tray icon first.
- For files on a USB drive or network share, the lock may be on another PC. Close the file there, or disconnect and reconnect the drive.
- Keep a note of the exact error message. "The action can't be completed because the file is open in another program" points to a lock, while "You need permission to perform this action" points to permissions.
- Run Command Prompt and Process Explorer as administrator; without elevation, they cannot see or close many handles.
Troubleshooting
If the file still will not delete after a restart, the lock is probably held by a service or by Windows itself. Open Resource Monitor again and search for the handle; if the owner is a service such as the Windows Search indexer or your antivirus, pause that service temporarily from its own settings rather than killing it in Task Manager. If the owner is a system process you cannot safely stop, use Process Explorer to close only that specific handle, not the process.
If you get "Access is denied" even in Safe Mode, the problem is permissions or the file is read-only. Clear the Read-only attribute in Properties, then check the Security tab and take ownership if needed. If the file is on a drive that is failing, Windows may lock it to prevent corruption; back up your data first and check the drive with the built-in error-checking tool before deleting anything.
If deletion appears to succeed but the file reappears, a program is recreating it. Identify the app from the file's location and name, and change that app's settings or stop it from running at startup via Task Manager > Startup apps.
Frequently Asked Questions
Why does Windows say a file is in use when no program is open?
Background processes such as antivirus, sync clients, the search indexer, or Windows itself can hold a handle without any visible window. Resource Monitor or Process Explorer will show which one.
Is it safe to use Process Explorer to close a handle?
It is safe for handles owned by ordinary apps. Do not close handles owned by critical system processes; Process Explorer warns you, and ignoring that warning can crash or destabilise Windows.
Can I delete a file that is locked by Windows Update?
Often not while the update is pending. Finish or pause the update, restart, and try again. Files under C:\Windows\SoftwareDistribution can be cleared with the built-in Disk Cleanup tool rather than manually.
Does Safe Mode always unlock files?
It removes most third-party locks, but files held by core Windows services may still be locked. In that case, use Process Explorer or wait for the next restart.
What if the file is on a network share?
The lock may belong to another computer. Close the file on that machine, or ask its user to do so. Deleting from your PC will not release a handle held elsewhere.
Will a third-party unlocker damage my PC?
Reputable tools can work, but many free ones bundle unwanted software. Stick to Microsoft Sysinternals tools and built-in Windows features first.