ThisCalculator

Everyday

Delete Undeletable Files in Windows in 3 Steps

Updated · Standard formula, shown below

Delete Undeletable Files in Windows in 3 Steps

This guide shows you how to remove stubborn files or folders that Windows refuses to delete, often due to file locks, permission errors, or path length issues. You’ll learn three direct methods that work on most current Windows versions (10 and 11), without third-party tools. First, try the simplest approach, then escalate to the more forceful ones if needed.

What You’ll Need

  • Administrator account access (to run Command Prompt or PowerShell as admin)
  • The exact file path or folder name you want to delete
  • Close any program that might be using the file (e.g., a document open in Word, a video playing in a media player)

Step-by-Step

  1. Try the standard delete first. Right-click the file or folder and select Delete, or select it and press Shift+Delete for permanent removal (skips the Recycle Bin). If this works, you’re done. If you see an error like “File in Useâ€� or “Access Denied,â€� proceed to step 2.
  2. Use Command Prompt to force deletion.
    1. Press Win+R, type cmd, then press Ctrl+Shift+Enter to run as administrator. Click Yes on the UAC prompt.
    2. Type the following command and press Enter (replace the path with your actual file or folder):
      del /f /q "C:\path\to\file.txt" for a file, or rmdir /s /q "C:\path\to\folder" for a folder.
    3. If the command executes without error, the file is gone. If you still get “Access Denied� or “The process cannot access the file because it is being used by another process,� go to step 3.
  3. Take ownership and grant full control, then delete.
    1. Right-click the file or folder → Properties → Security tab → Advanced.
    2. Next to Owner, click Change. Type Administrators in the “Enter the object nameâ€� box, click Check Names, then OK. Check the box “Replace owner on subcontainers and objectsâ€� if it’s a folder, then click OK.
    3. Back in the Security tab, click Edit → select Administrators → check Full control under “Allow� → OK → OK.
    4. Now try deleting again using the normal method or the command in step 2.

Common Mistakes

  • Using the wrong command for a folder. del deletes files, not folders. Use rmdir for folders.
  • Missing quotes around paths with spaces. Always enclose the full path in double quotes, e.g., del "C:\My Files\test.txt".
  • Not running as administrator. The command prompt must be elevated, or you’ll get “Access Deniedâ€� even if you have admin rights.
  • Skipping the “Replace owner on subcontainersâ€� option. For folders, this is essential to change permissions on all contents.
  • Deleting system files you actually need. Only force-delete files you are certain are not required for Windows to run. Deleting critical system files can cause crashes or boot failures.

Tips

  • If the file is locked by a program, close all applications and try again. You can also restart Windows and try immediately after booting.
  • For files with extremely long paths (over 260 characters), use the \\.\ prefix in the command, e.g., del "\\?\C:\very\long\path\file.txt".
  • If the file is in use by a background process, use Task Manager to end the process first (right-click the process → End Task).
  • Consider using Safe Mode: restart Windows, hold Shift while clicking Restart, then go to Troubleshoot → Advanced options → Startup Settings → Restart → press 4 for Safe Mode. Many locks are not active in Safe Mode.

Troubleshooting

If the above steps don’t work, try these in order:

  • Check if the file is read-only or hidden. Right-click → Properties → uncheck Read-only and Hidden if they are checked.
  • Use PowerShell instead of Command Prompt. Run PowerShell as admin and use Remove-Item -Path "C:\path\to\file" -Force.
  • Boot into Safe Mode and try deleting. This often bypasses third-party locks.
  • Use the “Storage Senseâ€� or Disk Cleanup. For temporary files, go to Settings → System → Storage → Temporary files, and clean them.
  • If the file is in the Recycle Bin and won’t delete, empty the bin from the desktop. If that fails, restart and try again.
  • If you still get “Access Denied,â€� you may need to disable inheritance on the folder: in the Advanced Security Settings window, click Disable inheritance → Convert inherited permissions into explicit permissions, then add Administrators with full control.

Frequently Asked Questions

Why does Windows say “The action can’t be completed because the file is open in another programâ€�?

This means a process is currently using the file. Close the program that has it open. If you don’t know which one, restart your computer and try deleting immediately after booting.

What does “Access Denied� mean when deleting?

It usually means your user account doesn’t have permission to modify or delete the file. Taking ownership and granting full control, as shown in Step 3, typically resolves this.

Can I delete a file that is locked by a system process?

Sometimes, but it’s risky. If the file is part of Windows (e.g., in C:\Windows), deleting it can break your system. For non-system files, you can often unlock them by ending the process in Task Manager or using Safe Mode.

Is it safe to use Command Prompt to delete files?

Yes, but only if you are certain the file is not needed. The /f flag forces deletion of read-only files, and /q suppresses confirmation prompts. Double-check the path before pressing Enter.

What if the file is in use by a virus or malware?

Don’t try to delete it manually. Run a full antivirus scan first. If the malware is active, it will recreate the file. Use your antivirus’s removal tool or boot into Safe Mode with Networking to run a scan.

How do I delete a file with a very long path?

Use the \\?\ prefix in the command, like del "\\?\C:\extremely\long\path\file.txt". This tells Windows to skip the path length limit.

Related

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