Windows 11 Won't Let Me Delete a File — "File Is Open in Another Program" Fix

By Adhen Prasetiyo

Thursday, May 7, 2026 • 5 min read

Windows 11 error dialog showing the action cannot be completed because the file is open in another program

Windows 11 Won’t Let Me Delete a File — “File Is Open in Another Program”

One of the most infuriating Windows messages ever invented:

The action can’t be completed because the file is open in another program. Close the file and try again.

What program?? You closed everything. You don’t have anything open. You restarted the computer twice. The file is still “open” somewhere according to Windows. Where??

This was driving me nuts last month when I was trying to clean out an old project folder and one specific PDF refused to delete. I closed every app I could think of. Restarted. Nothing. The file just sat there mocking me.

There are actually a few different things that can cause this, and once you know what they are, the fix is fast.

Why This Happens

When any program reads or writes to a file, Windows puts a “lock” on it. This is to prevent two programs from messing with the same file at the same time and corrupting data. The lock is supposed to release as soon as the program is done with the file. But sometimes:

  • A program crashes without releasing the lock
  • A background service (you don’t see it as an open window) is still using the file
  • Windows itself is holding the file (like the search indexer scanning it)
  • The file is in use by your antivirus during a scan
  • Microsoft Defender’s controlled folder access is being weird about it
  • A thumbnail preview is being generated

The last one is really common with images and videos — the moment you click on a folder containing them, Windows generates thumbnails for the preview pane, and that process locks the files for a few seconds.

The Quickest Fix First

Before going deep, try the easy stuff:

  1. Close File Explorer completely (right click taskbar → Task Manager → find Windows Explorer → End task)
  2. Reopen File Explorer (Task Manager → File → Run new task → type “explorer.exe” → Enter)
  3. Try deleting the file again

This works probably half the time. File Explorer itself often holds onto files for thumbnail generation or preview pane stuff, and restarting it forces it to let go.

When That Doesn’t Work — Find the Process

If the easy fix didn’t work, you need to find which exact program is holding the file. Windows actually has a built-in tool for this called Resource Monitor that most people don’t know about.

Open Task Manager → Performance tab → at the bottom, click Open Resource Monitor. Or just press Win + R and type resmon.

In Resource Monitor, click the CPU tab. Find the section called Associated Handles (it’s collapsed by default — click the arrow). There’s a search box. Type the filename of the file you can’t delete. Resource Monitor will show every process currently holding that file.

Magic, right? Now you can right click the process listed and choose End Process. The file should be deletable immediately after.

Fair warning: if it shows “explorer.exe” or something critical, killing it might cause weird behavior. Restart your computer instead in those cases.

The Nuclear Option

If Resource Monitor shows the file is held by something you absolutely can’t kill (or shows nothing at all and the file STILL won’t delete), there’s one more option that always works.

Open Command Prompt as Administrator (right click the start button, choose Terminal Admin or Command Prompt Admin). Then type:

del /f /q "C:\path\to\your\file.ext"

The /f flag forces deletion even with read-only attribute. The /q flag means quiet mode (no confirmation prompts). This bypasses some of the GUI-level checks Windows does and can delete files that File Explorer refuses to.

If even THAT doesn’t work, the file is held at a kernel level (rare but possible). The only fix then is to boot into Safe Mode and delete it from there. Safe Mode loads minimal Windows so most background processes aren’t running.

Special Case: OneDrive Files

If the file is inside your OneDrive folder, it might be locked because OneDrive is syncing it. Pause OneDrive sync (right click OneDrive icon → Pause syncing → 2 hours), then try to delete. After the deletion succeeds, resume sync and OneDrive will sync the deletion to the cloud.

This was actually my problem with that PDF — OneDrive had been stuck in a sync loop for that specific file for who knows how long. Pausing sync and deleting locally fixed it instantly.

Special Case: Files Used by Services

Some files are used by Windows services that run silently in the background. Things like:

  • Antivirus quarantine files
  • Printer spool files (locked by Print Spooler service)
  • Database files used by indexing services

If Resource Monitor shows the holder is something like svchost.exe, you can’t just kill svchost (it’d crash Windows). Instead:

  1. Open Services (Win + R, type services.msc)
  2. Find the related service (like “Print Spooler” if it’s a print job)
  3. Right click → Stop
  4. Try to delete the file
  5. Right click the service → Start to turn it back on

Prevention

For what it’s worth, you can avoid most of these issues by:

  • Not editing files inside Windows Defender’s Controlled Folders if you have that enabled
  • Closing all your apps before doing big folder cleanups
  • Avoiding the Documents and Desktop folders for project files (use a separate drive or folder if possible)

But honestly, this is a Windows annoyance you’ll deal with forever. Bookmark this article — you’ll need it again. I sure did.

Step-by-Step Guide

1

Restart Windows Explorer first

Right click the taskbar and pick Task Manager. Find Windows Explorer in the Processes tab. Right click it, choose Restart. Your taskbar will disappear for a second and come back. Now try deleting the file again. About half the time, this just fixes it because Explorer was holding the file for thumbnail or preview generation. If this doesn't work, move to the next step.

2

Open Resource Monitor to find the actual culprit

Press Windows + R, type resmon, hit Enter. Resource Monitor opens. Click the CPU tab at the top. Scroll down and find the Associated Handles section. Click the arrow to expand it. There's a search box with text saying Filter by handle name. Type your filename (just the name, no path needed). Resource Monitor will show you every process currently holding that file. Now you know exactly what to kill.

3

End the process holding the file

In the Associated Handles list, right click the process name (like notepad.exe or whatever it shows) and choose End Process. Confirm. The handle releases immediately. Switch back to File Explorer and try to delete the file. It should work instantly. If the process listed is something critical like explorer.exe or svchost.exe, don't kill it directly — restart your computer instead, that'll release the handle without breaking anything.

4

Force delete via Command Prompt as last resort

If Resource Monitor shows nothing or the process can't be killed, open Command Prompt as Administrator (right click Start button, pick Terminal Admin). Type del /f /q followed by the full path to your file in quotes, like del /f /q "C:\Users\YourName\Documents\stubborn-file.pdf" and hit Enter. The /f forces it even with read-only attribute, /q makes it not ask for confirmation. This bypasses GUI checks and works on most files that File Explorer refuses to touch.

5

Boot into Safe Mode for stubborn files

If even Command Prompt can't delete the file, boot into Safe Mode. Press Windows + R, type msconfig, go to the Boot tab, check Safe boot, click OK and restart. In Safe Mode, hardly any background processes run, so file locks are minimal. Delete the file normally. After it's deleted, run msconfig again, uncheck Safe boot, restart back to normal Windows. This works for files that are held at the system level by services that load early in the boot process.

Frequently Asked Questions

Why does Windows lock files I'm not even using?
Lots of background processes touch your files without you knowing. Windows search indexer scans them. Antivirus checks them. File Explorer generates thumbnails for previews. Cloud sync apps like OneDrive watch them. Any of these can hold a temporary lock that prevents deletion. Most release the lock quickly, but sometimes a process gets stuck.
Is it safe to use the del /f command?
Yes, completely safe. It just forces deletion of the file you specified. It can't accidentally delete other files. The /f flag only means it ignores the read-only attribute — it doesn't bypass any actual safety mechanisms. Just make sure you typed the path correctly because deleted files don't go to the Recycle Bin with /f.
I deleted the file but it keeps coming back. What's happening?
Something is recreating it. Could be a sync app like OneDrive or Dropbox restoring it from the cloud. Could be a backup software. Could be malware (in rare cases). Pause your sync apps first. If it still comes back, the program creating it is running. Use Resource Monitor to find what's writing to that path and disable that program.
Can I delete a folder if files inside are locked?
No, deleting a folder requires deleting all files inside first. If even one file is locked, the whole folder deletion fails. Find and unlock the specific file using the Resource Monitor method, then delete the folder normally.
Adhen Prasetiyo

Research Bug bounty at javahack team

Research Bug bounty Profesional

Web Development Research Bug Hunter
View all articles →