Quick fix: Open Resource Monitor → CPU tab → Associated Handles section, search for the filename, identify the process holding it, and end that process — the file becomes deletable immediately.
You try to delete a file in Explorer and get the dialog: The action can’t be completed because the file is open in another program. You close every visible app, log out and back in, and the error persists. Some background process or service is holding an exclusive handle on the file, and Windows won’t let you delete it until that handle is released. The good news: identifying the culprit takes 30 seconds.
Affects: Windows 11 (and Windows 10) when any process — visible or background — has an open handle on the target file.
Fix time: ~2 minutes.
What causes this
NTFS enforces file sharing modes set by each process that opens a file. A process can request exclusive access (no other process can open the file at all) or shared access (others can read but not write or delete). When Explorer tries to delete a file, NTFS asks every existing handle whether it permits the deletion. If any handle says no — or simply hasn’t been closed yet — the deletion fails.
Common culprits include: antivirus real-time scanners (Defender, third-party AV), search indexers, OneDrive sync, Windows Search, video thumbnail generators, code editors with autosave, and any media player still pointing at the file.
Method 1: Find and kill the locking process via Resource Monitor
The most direct route. Identifies the exact process holding the handle.
- Press
Win + R, typeresmon, press Enter. - Switch to the CPU tab.
- Expand the Associated Handles section near the bottom.
- In the Search Handles box, type part of the locked file’s name (e.g., report.pdf).
- The grid below shows every process with a matching handle, with the column Image identifying it (e.g., OneDrive.exe, MsMpEng.exe, Acrobat.exe).
- If the process is non-essential, right-click it in the grid and choose End Process.
- For a system process you can’t kill (typically System itself, indicating an SMB lock or a kernel driver), continue to Method 2.
The deletion should succeed instantly after the offending process exits. If it doesn’t, refresh Explorer with F5 and try again.
Method 2: Use handle.exe for handle-level closure
When the locking process is essential and you can’t kill it, Microsoft’s Sysinternals handle.exe can close individual handles without ending the process.
- Download Sysinternals Suite from learn.microsoft.com/sysinternals and extract
handle.exeto a folder likeC:\Tools\Sysinternals. - Open Terminal (Admin) and navigate to that folder (
cd C:\Tools\Sysinternals). - Run
handle.exe -nobanner "report.pdf"(replace with your filename). The output lists every process with the file open, along with a hex handle ID. - Example output:
Acrobat.exe pid: 12384 type: File 1A4: C:\Users\you\Documents\report.pdf. The handle ID is1A4. - Close the handle without ending the process:
handle.exe -nobanner -c 1A4 -p 12384. Confirm with y when prompted. - Try the deletion from Explorer immediately afterward.
This is the surgeon’s tool — useful when the locking process is a service you don’t want to interrupt (a database, a build agent, an SMB share).
Method 3: Boot into Safe Mode and delete
The fallback when something deep in the kernel won’t let go.
- Open Settings → System → Recovery.
- Click Restart now next to Advanced startup.
- From the boot menu choose Troubleshoot → Advanced options → Startup Settings → Restart.
- On the next screen press 4 for Safe Mode.
- Sign in. Almost no background services run in Safe Mode — services like OneDrive, Search, and most antivirus are off. Delete the file from Explorer.
- Restart normally. The file is gone, and Windows resumes its normal startup.
This works for the rare case where a kernel driver or NTFS itself is holding the file open. It’s slow because it requires a reboot, but it succeeds nearly 100% of the time.
How to verify the fix worked
- The file is no longer in Explorer at its original path.
- Running
handle.exe -nobanner "filename"returns No matching handles found. - Check the Recycle Bin if you deleted with
Deleterather thanShift+Delete— the file should be present there until you empty.
If none of these work
If the file resists deletion even from Safe Mode, the underlying NTFS state may be damaged. Run chkdsk C: /f from an elevated Command Prompt and reboot to let it scan on next startup. CHKDSK often clears orphaned handles in its filesystem repair pass. If the file is a renamed-or-corrupted system file (typically with names like ~SD123.tmp in System32), it may be an in-use installer artifact — leaving it alone is safer than forcing deletion, since some installers create these as locks and clean them on reboot. For files in a OneDrive or SharePoint folder that won’t delete despite no visible lock, the issue is the sync engine — pause OneDrive sync from the cloud icon, delete the file, then resume sync.
Bottom line: A locked file is almost always held by a specific process you can identify in Resource Monitor — kill that process or close the handle, and Windows lets the file go.