How to Force Delete a Folder in Windows 11

To force delete a folder in Windows 11, open Command Prompt and run rmdir /s /q "C:\path\to\folder". The /s switch removes the folder with every file and subfolder inside it, and /q skips the confirmation prompt. If Windows says the folder is in use or access is denied, the fixes below cover each case, from closing the app that’s holding it to restarting in Safe Mode.

These steps are for Windows 11 versions 24H2 through 26H2, and the commands also work in Windows 10.

Before you start: rmdir and Shift + Delete skip the Recycle Bin, so copy what you need and check the path. Never run these on C:\Windows or C:\Program Files; uninstall programs from Settings > Apps.

Common Reasons a Folder Won’t Delete

Message or symptom Usual cause Fix
The action can’t be completed because the folder or a file in it is open in another program An app has a file open Close the app, or use File Locksmith
You need permission to perform this action or Access is denied Your account doesn’t own the folder Run as administrator, then take ownership
The directory is not empty Hidden, system or read-only files are inside Clear the attributes with attrib
The filename or extension is too long The path is very deep or the name is invalid Use the \\?\ prefix
The folder comes back after deleting An app or sync service recreates it Uninstall the app or stop syncing

Try a Normal Delete First

Most “can’t delete” errors happen because an app still has a file in the folder open.

  1. Save your work and close any app that might be using a file in the folder, such as a document, a video, or a code editor.
  2. In File Explorer, click a different folder so the preview pane isn’t showing a file from the one you’re deleting.
  3. Right-click the folder and click the Delete (trash can) icon. The folder moves to the Recycle Bin, where you can still restore it. Or select it and press Shift + Delete, then click Yes, to skip the Recycle Bin.
  4. If the same error appears, restart the PC and try again before opening anything else.

If you can’t tell which app is involved, open Task Manager with Ctrl + Shift + Esc and close the app from the Processes tab with End task. If File Explorer itself seems stuck, select Windows Explorer in the same list and click Restart.

If the folder is inside OneDrive, deleting it also removes it from the cloud and from your other devices. If you only want to free up space on the PC, read deleting files from OneDrive on Windows 11 first.

Force Delete the Folder With Command Prompt

  1. In File Explorer, right-click the folder and click Copy as path. This copies the full path in quotation marks.
  2. Click Start, type cmd, and open Command Prompt. A regular window is fine for a folder in your own user profile. For other folders, right-click Command Prompt and choose Run as administrator, then click Yes.
  3. Type rmdir /s /q, add a space, and press Ctrl + V to paste the path. The command looks like this:
Command Prompt with an rmdir /s /q command to delete a folder
rmdir /s /q removes the folder and everything inside it.
rmdir /s /q "C:\Users\YourName\Downloads\Old Project"
  1. Check that the path ends with the folder you want to delete, not its parent. Then press Enter.
  2. If Command Prompt returns to a new line with no message, the folder is gone. Refresh File Explorer to confirm.

Keep the quotation marks around the path. Without them, a folder name with a space in it, like Old Project, is read as two separate folders.

Microsoft’s rmdir reference notes that rd is the same command, so rd /s /q works too. If you’d like a chance to back out, leave off /q. Windows then asks Are you sure (Y/N)? before deleting.

One catch: you can’t delete the folder Command Prompt is currently working in. If the prompt line shows a path inside the folder you’re deleting, type cd \ and press Enter first, then run the command again.

If You See “The Directory Is Not Empty”

Without /s, rmdir won’t delete a folder that still has files in it, including hidden or system files you can’t see in File Explorer. Run the command with /s first. If it still fails, clear the read-only, hidden and system attributes on everything inside, then delete:

attrib -r -h -s "C:\path\to\folder\*" /s /d

The /s switch covers every subfolder, and /d applies the change to folders as well as files. Microsoft’s attrib reference lists these options. Then run the rmdir /s /q command again.

If the Folder Is in Use by Another Program

When you see The process cannot access the file because it is being used by another process, something still has a file open. If you can’t tell what, Microsoft’s free PowerToys includes a tool called File Locksmith that shows you.

  1. Install PowerToys from the Microsoft Store if you don’t already have it, open it, and turn on File Locksmith.
  2. In File Explorer, right-click the folder, click Show more options, then click Unlock with File Locksmith. It scans the folder and all its subfolders.
Unlock with File Locksmith in the File Explorer right-click menu
File Locksmith shows which programs are holding the folder.
  1. Review the list of programs. Close each one normally if you can, or click End task. Ending a task loses any unsaved work in that program.
  2. If the list looks incomplete, click Restart as administrator to see processes run by other accounts.
  3. Run the rmdir command again.

Don’t end processes you don’t recognize, especially ones with Windows or system names. Restarting the PC is a safer way to release them.

If You Get “Access Is Denied”

This means your account doesn’t have permission to delete the folder, which is common with folders copied from another PC or another user account, or from an external drive. First, try the rmdir command again in an administrator Command Prompt (here’s how to run Command Prompt as admin).

If that still fails and the folder holds your own files, you can take ownership of that one folder and give administrators full control. Use this only on personal folders such as an old project or a copied backup, never on any of the Windows or program folders listed at the top of this article.

  1. Take ownership of the folder and everything in it:
takeown /f "C:\path\to\folder" /r /d y
Administrator Command Prompt after taking ownership of a folder with takeown
Take ownership first, then grant permissions and delete.

The /r switch includes all subfolders, and /d y answers yes for subfolders you currently can’t read. Microsoft documents these switches in its takeown reference.

  1. Give the Administrators group full control:
icacls "C:\path\to\folder" /grant administrators:F /t

F means full control, and /t applies it to every file and subfolder.

  1. Delete the folder:
rmdir /s /q "C:\path\to\folder"

Because the folder is deleted right after, the permission change doesn’t stay behind. On a work or school PC, ask your IT department instead. If the folder is on a USB drive or memory card, also check that the drive isn’t full or write-protected, since Windows can’t delete anything from a locked drive.

If the Path Is Too Long or the Name Is Invalid

Folders buried many levels deep, or with names ending in a space or a period, can fail with errors like The filename or extension is too long or The system cannot find the file specified. Microsoft’s file naming rules explain that File Explorer can’t handle names like these even when the drive allows them. Adding \\?\ in front of the full path tells Windows to skip its normal path checks:

rmdir /s /q "\\?\C:\path\to\folder"

The path must be complete, starting with the drive letter, for this prefix to work.

Delete the Folder in Safe Mode

If a program or service starts with Windows and keeps grabbing the folder, Safe Mode loads only the basics so you can delete it.

  1. Open Settings > System > Recovery.
  2. Next to Advanced startup, click Restart now, then confirm. You can also hold Shift while you click Power > Restart on the Start menu.
  3. On the blue screen, click Troubleshoot > Advanced options > Startup Settings > Restart.
  4. When the list appears, press 4 or F4 for Enable Safe Mode.
  5. Sign in, delete the folder in File Explorer or with rmdir, then restart normally.

If your PC uses BitLocker or device encryption, have your recovery key handy before you restart into Advanced startup, since Windows may ask for it. Microsoft’s Startup Settings guide lists the other startup options.

Force Delete Folder Questions

Can I get a folder back after deleting it with rmdir?

Not from the Recycle Bin. Your options are a backup, OneDrive’s own recycle bin if the folder was synced, or File History if you’d turned it on. Finding deleted files on Windows 11 shows where to look.

Can I force delete a folder with PowerShell instead?

Yes. In PowerShell, run Remove-Item -LiteralPath "C:\path\to\folder" -Recurse -Force. It does the same job as rmdir /s /q and also skips the Recycle Bin.

Why does the folder come back after I delete it?

An installed app or a sync service is recreating it. Uninstall the app or change its settings, or remove the folder from OneDrive’s sync, then delete it again.

I deleted the folder normally. Why is my drive space the same?

The folder is in the Recycle Bin and still uses space. Empty the Recycle Bin once you’re sure you don’t need it.

What about a single file that won’t delete?

The same causes apply, but the commands are slightly different. Read-only and locked files are covered in force deleting a file in Windows 11.