How Do You Delete a File That Is Locked by Another Process on Windows?

Updated

Use a file unlocker such as LockHunter to see which process is holding the file, then unlock, delete, rename, or schedule deletion at the next restart. This applies when Windows refuses to delete a file with a "file in use" or "being used by another program" message. If the error instead says you need permission from an administrator or the file is read-only, the cause is permissions or attributes, not a process lock, and an unlocker will not help.

Recognize a process lock

A process lock usually shows up as:

  • "The action can't be completed because the file is open in another program."
  • "Cannot delete file: It is being used by another person or program."
  • Deletion succeeds only after you close a specific app, or fails again as soon as it restarts.

A permissions problem looks different: "You need permission to perform this action" or "Access is denied," often on files owned by another account or protected by system attributes. Check the message before reaching for an unlocker.

Identify the locking process with LockHunter

LockHunter is a free 32/64-bit Windows tool (version 3.4.3, about 3.2 MB, for Windows 11/10/8.1/7) built for exactly this case. Its documented features:

  • Shows the processes locking a file or folder.
  • Gives detailed information on each process.
  • Lets you unlock, delete, copy, or rename a locked file.
  • Can delete a file at the next OS restart.
  • Can kill the locking process or remove it from the hard drive.
  • Can unload DLLs from processes.
  • Integrates into the Explorer menu.

A practical sequence:

  1. Open the file in LockHunter. Either launch the tool and browse to the file, or right-click it in Explorer and use the integrated menu entry.
  2. Read the process list. The tool lists which processes hold the file, with details on each. Confirm the process is one you recognize before acting.
  3. Choose an action based on what you find:
    • Unlock if you only need the handle released and want to keep the file.
    • Delete if the file should go. LockHunter deletes into the Recycle Bin, so a mistaken deletion can be restored.
    • Rename or copy if you need to preserve the file but move it out of the way.
    • Delete at next restart if the lock cannot be released while Windows is running.
  4. Verify. Check that the file is gone from its location, and check the Recycle Bin if you expected it there.

Handle stubborn locks

Some locks survive a simple unlock attempt:

  • Malware or unknown programs. LockHunter is explicitly positioned for fighting malware and programs that block files without reason. If the locking process is unfamiliar, identify it before killing it; killing a system process can destabilize Windows.
  • DLLs loaded into processes. A DLL held by a running process cannot be deleted normally. LockHunter can unload DLLs from processes, which addresses this case.
  • Processes that restart immediately. If killing the process only brings it back, schedule deletion at the next OS restart so the file is removed before the process can re-lock it.
  • Removing the locking process from disk. LockHunter can remove locking processes from the hard drive, useful when the process itself is unwanted.

Choose the right action

Situation Action Why
You need the file, just not the lock Unlock Releases the handle without deleting
File is unwanted and the lock is temporary Delete Goes to Recycle Bin, restorable
File must be preserved but relocated Rename or copy Avoids deletion entirely
Lock returns every time Delete at next restart Runs before the process can re-lock
Locking process is malicious or unwanted Kill or remove the process Eliminates the source of the lock

Cautions

  • Deleting into the Recycle Bin protects against mistakes, but emptying the bin makes the deletion permanent.
  • Killing processes can lose unsaved work in those applications; save what you can first.
  • If the file is protected by permissions rather than a lock, fix ownership or attributes instead of forcing deletion.
  • LockHunter is described as free on its site; no pricing or login requirements are stated beyond that.