ThisCalculator

Everyday

Delete File in Use by Another Program: Fixes

Updated · Standard formula, shown below

To delete a file that another program is using, you must first close the program holding it or end the process that has the file open. If you cannot find or close the program, you can use built-in tools like Task Manager, or a free utility like Microsoft’s Process Explorer, to identify and release the lock before deleting the file.

Why Windows Locks Files

Windows prevents you from deleting, moving, or renaming a file while a program has it open. This is a safety feature: the operating system assumes the program still needs the file’s data. The lock is enforced by the NTFS file system, which tracks open handles (references) for each file. When you try to delete a locked file, you get an error such as “The action can’t be completed because the file is open in another program” or “The file is in use by another process.”

Common culprits include:

  • Media players (a video or audio file you’re watching or listening to)
  • Word processors or PDF readers (a document you have open)
  • File Explorer itself (a preview pane or thumbnail cache)
  • Antivirus scanners (temporarily scanning a downloaded file)
  • Background services (like indexing or backup software)

First Steps: Close the Obvious Program

Start with the simplest fix: close the program you think is using the file. If you’re not sure, close all open applications and try again. If the file is still locked, restart File Explorer (explorer.exe) because it sometimes holds handles for files you’ve recently viewed.

  1. Press Ctrl+Shift+Esc to open Task Manager.
  2. Under Processes, look for the program that might be using the file (e.g., a video player, document viewer).
  3. Right-click it and select End task.
  4. Try deleting the file again.

If you don’t see an obvious program, or the file is still locked, proceed to the next steps.

Find the Exact Process with Process Explorer

When you can’t guess which program has the file open, use Microsoft’s free Process Explorer (part of the Sysinternals suite). It shows every open file handle on your system, and you can search for your file by name.

  1. Download Process Explorer from the official Microsoft Sysinternals page.
  2. Run it (no installation needed).
  3. Press Ctrl+F to open the search box.
  4. Type the file name (or part of it) and click Search.
  5. The results list shows which process(es) have a handle to that file.
  6. Double-click the result to jump to the process in the main list.
  7. Right-click the process and choose Kill Process (or Close Handle if you only want to release that one handle).

Killing a process is more forceful than closing a window, so save any unsaved work in other programs first. After the process is gone, delete the file.

Use Task Manager’s “Details” Tab

If you already know the program but it doesn’t show a window (e.g., a background service), you can find it in Task Manager’s Details tab. This lists all running processes, including background ones.

  1. Open Task Manager (Ctrl+Shift+Esc).
  2. Click the Details tab.
  3. Sort by the Name column to find the process you suspect.
  4. Right-click it and select End task.

Be careful: some processes are system services. Ending a critical system process can cause a crash or require a restart. Only end processes you recognize as belonging to a program you installed.

When the File Is Locked by Explorer or System

Sometimes the lock comes from Windows itself. Common examples:

  • File Explorer preview pane: If you selected a file and the preview pane is open, Explorer holds a handle. Close the preview pane (View > Preview pane) and try again.
  • Thumbnail cache: A file that has been displayed as a thumbnail may be briefly locked. Restart Explorer (right-click taskbar > Task Manager > Details > explorer.exe > End task, then File > Run new task > explorer.exe).
  • Windows Search indexer: It may be scanning a large file. Wait a few minutes and retry.
  • Antivirus: Some antivirus tools lock files during a scan. Pause real-time protection temporarily (if you trust the file) and try again.

Alternative: Schedule Deletion on Restart

If you can’t release the lock at all, you can schedule the file to be deleted on the next restart, before any program opens it. This works because Windows performs the deletion early in the boot process.

  1. Open a command prompt as administrator (search “cmd”, right-click, “Run as administrator”).
  2. Type the following and press Enter:
move "C:\path\to\file" "C:\path\to\file" /y

That command is a trick: it uses move with the same source and destination, which forces Windows to mark the file for deletion on reboot. A more direct method is to use the DeleteFile API via a small script, but the move trick is built-in and works for most files.

After running the command, restart your computer. The file should be gone.

Common Mistakes and Misconceptions

Many people try to use third-party “unlocker” tools that may be outdated or bundled with unwanted software. Stick with Microsoft’s Process Explorer or the built-in methods above.

Another misconception is that you can delete a file by renaming it first. On NTFS, renaming also requires write access to the file’s directory entry, but the file lock prevents that too. You’ll get the same error.

Also note: if the file is on a network share, the lock may come from another computer. In that case, you need to ask the remote user to close the file, or check who is connected via the server’s management console.

Frequently Asked Questions

Why does it say “file in use” even after I closed all programs?

Some programs run background processes that stay active after you close the main window. For example, a media player might keep a tray icon running. Open Task Manager and look for the program’s process under Details. Also, File Explorer itself can hold a handle if you had the file selected or previewed.

Can I force delete a file with CMD?

Yes, you can try del /f /q "path" in an elevated command prompt. The /f forces deletion of read-only files, but it does not bypass a lock. If the file is locked, you’ll still get an error. The move trick described above is more effective for locked files.

Is it safe to end a process in Task Manager?

It’s safe for user applications (like Word or Chrome) because you may lose unsaved work but won’t harm the system. Ending system processes (like svchost.exe or explorer.exe) can cause instability; Windows will usually restart them, but save your work first.

What if the file is locked by a system process like System or Antimalware Service?

These are often temporary locks during scans or indexing. Wait a few minutes and retry. If the lock persists, restart your computer. If it still persists, the file may be corrupted or part of a system component; do not force-delete system files unless you are certain they are not needed.

Does unlocking a file delete the program that uses it?

No. Unlocking just releases the handle so you can delete the file. The program itself remains installed. If you delete a file that a program needs (like a DLL or a save file), the program may error or lose data, so only delete files you are sure you no longer need.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.