☕ Buy a Coffee
Home / Windows & SysAdmin

Force-Delete a File That Says 'In Use by Another Program'

Use Resource Monitor and PowerShell handle lookups to identify locking process PIDs and release locked file handles without rebooting.

Sachin Siju
Sachin Siju
Lead Systems Engineer & Tech Blogger
Jul 17, 2026 3 min read
Force-Delete a File That Says 'In Use by Another Program'

Why Windows Refuses to Delete the File

When you see "The action can't be completed because the file is open in another program", some process holds an open file handle on it — the file might be memory-mapped, locked for writing, or simply left open by an app that crashed without releasing it. Windows won't let you delete or move a file while any process holds a handle to it. Rebooting always clears every handle, but you don't need to reboot just to delete one stubborn file — you can find and release the specific handle instead.

Step 1: Try the Obvious Fix First

Before digging into handles, rule out the simple case: check every open window and every icon in your system tray for the app that might be using the file (a video still "open" in VLC, a document open in Word, a folder open as the working directory of a Command Prompt window). Close it and retry the delete. This resolves the majority of cases in seconds.

Step 2: Find the Locking Process With Resource Monitor

  1. Press Win, type resmon, and open Resource Monitor.
  2. Click the CPU tab.
  3. Scroll to the Associated Handles panel near the bottom.
  4. In the search box above that panel, type part of the file's name (not the full path — just the filename is usually enough) and press Enter.

Resource Monitor searches every open handle system-wide and lists any process holding one that matches. The result shows the process name and its PID (Process ID).

Tip: if the search comes back empty, the file might not actually be locked by a handle — it could be an antivirus scan in progress, a sync client (OneDrive, Dropbox) mid-upload, or a permissions issue masquerading as a "file in use" error.

Step 3: End the Locking Process

Once you've identified the offending process in Resource Monitor, right-click it in the Associated Handles list and choose End Process. Confirm the warning, then retry the delete — it should now succeed.

Be careful what you kill: if the process is explorer.exe, a system service, or something you don't recognize, ending it can cause other side effects (Explorer will restart itself automatically if killed, but other system processes may not recover gracefully). If in doubt, look up the process name before terminating it.

Alternative: PowerShell With Sysinternals Handle

For a faster, scriptable version of the same lookup, download Handle (handle.exe) from the Sysinternals Suite (Microsoft-owned, safe, no install needed — just an executable). Run it from an elevated Command Prompt or PowerShell:

.\handle64.exe "C:\path\to\locked_file.txt"

The output lists the process name, PID, and handle ID, for example:

notepad.exe          pid: 7124  type: File  4C: C:\path\to\locked_file.txt

You can then force-close just that handle without killing the whole process:

.\handle64.exe -c 4C -p 7124 -y

Or, more simply, just kill the whole process by PID:

Stop-Process -Id 7124 -Force

Step 4: Force-Delete the File

Once the handle is released, a normal delete works. If the file is still stubborn (permissions issue rather than a lock), try taking ownership and forcing deletion from an elevated prompt:

takeown /f "C:\path\to\locked_file.txt"
icacls "C:\path\to\locked_file.txt" /grant administrators:F
del /f /q "C:\path\to\locked_file.txt"

/f forces deletion of read-only files, and /q suppresses the confirmation prompt.

Last Resort: Delete on Next Reboot

If nothing above works — the process won't release the handle cleanly, or it's a system-critical process you can't safely kill — you can schedule the file for deletion the next time Windows boots, before most processes (and their locks) exist. Sysinternals' MoveFile tool does this:

.\movefile.exe "C:\path\to\locked_file.txt" ""

Passing an empty string as the destination schedules a delete-on-reboot instead of a move. Reboot, and the file will be gone before Windows finishes starting up.

Quick Reference

  • GUI route: Resource Monitor > CPU tab > Associated Handles > search filename > End Process.
  • Command-line route: handle64.exe "filename" to identify, then Stop-Process or targeted handle close.
  • Permissions issue instead of a lock: takeown + icacls + del /f /q.
  • Nothing works: schedule delete-on-reboot with movefile.exe, or just reboot and delete normally.
Featured Infrastructure Partner

Deploy on High-Performance Hostinger Cloud

Get up to 75% OFF + free domain & SSL. Powering xube.me's sub-second response times.

Claim Discount ↗

Discussion & Insights

Related Technical Essays