To force delete a file or folder in Windows, open Command Prompt as administrator and run del /f on the file or rmdir /s /q on the folder, after closing whatever program is holding it open.
When that is refused, the cause is a lock, missing ownership or file system damage, and each has its own fix below for Windows 11 and Windows 10.

How to force delete a file or folder in Windows
Start with the reason Windows gives. Each refusal points to one fix, and using the right one first saves you from taking ownership of a folder that was only open in an app.
| What Windows tells you | What is blocking the delete | Do this |
|---|---|---|
| The file is open in another program, or the process can't access the file because it is being used by another process | An app, a background process or File Explorer itself holds the file | Close the app or restart the PC; if you cannot tell which app it is, use File Locksmith |
| The item is read-only, hidden or a system file | File attributes block a normal delete | Use del /f or attrib -h -s in Command Prompt |
| You need permission to delete the item | Another account or Windows owns it | Take ownership with takeown and icacls, then delete |
| The directory is not empty | Hidden or system files are still inside the folder | Use rmdir /s /q, which removes the whole tree |
| The file or folder is corrupted and unreadable | File system errors on the drive | Run chkdsk /f on the drive, restart, then delete |
| The lock comes back every time Windows starts | A startup app or driver opens the file at boot | Delete it from Safe Mode |
Command-line deletes skip the Recycle Bin. For everyday deletes that you may want to undo, delete files and folders in Windows 11 from File Explorer instead.
Force delete a file or folder in Windows using Command Prompt
del removes files and rmdir removes folders. Run them from an elevated Command Prompt so they act with administrator rights, and put any path that contains spaces in double quotes.
- Type cmd in the search box on the taskbar, right-click Command Prompt and select Run as administrator, then select Yes.
- To force delete a single read-only file, type
del /f /q "C:\Path\File.txt"and press Enter./fforces deletion of read-only files and/qskips the confirmation prompt. - If the file is also hidden or a system file, clear those attributes first with
attrib -h -s "C:\Path\File.txt", then run thedelcommand again. - To force delete a folder and everything in it, type
cd \so the prompt is not inside that folder, becausermdircannot delete the current directory. - Type
rmdir /s /q "C:\Path\Folder"and press Enter./sdeletes the folder with all its subfolders and files, and/qruns without asking for confirmation. - Type
dir "C:\Path"to see that the file or folder no longer appears in the parent folder.
A file deleted with del cannot be retrieved from the Recycle Bin, and rmdir /s /q removes the whole tree with no prompt. Check the path twice before you press Enter.
Force delete a folder with PowerShell Remove-Item -Force
Remove-Item -LiteralPath "C:\Path\Folder" -Recurse -Force
Run it in PowerShell or Windows Terminal opened as administrator. -Recurse deletes the folder and every child item, -Force removes items that cannot otherwise be changed, such as hidden or read-only files, and -LiteralPath uses the path exactly as typed, so brackets and other wildcard characters in a name are not misread. Even with -Force, Remove-Item cannot override security restrictions, so a folder that refuses for permission reasons still needs the ownership fix below.
You should see: PowerShell returns to the prompt with no message, and Test-Path "C:\Path\Folder" returns False.
Take ownership of a file or folder with takeown and icacls to delete it
When an item belongs to another account or to an old Windows installation, administrator rights alone do not let you delete it. takeown makes you the owner and icacls grants full control, after which a normal delete works.
- Open Command Prompt as administrator.
- Type
takeown /f "C:\Path\Folder" /a /r /d yand press Enter./agives ownership to the Administrators group,/rapplies it to every file and subfolder, and/d yanswers yes for folders you cannot list. - Type
icacls "C:\Path\Folder" /grant administrators:F /t /cand press Enter.Fis full access,/tcovers all subfolders and/ckeeps going past individual file errors. - Type
rmdir /s /q "C:\Path\Folder"to delete the folder, ordel /f /q "C:\Path\File.txt"for a single file. - If the delete still fails with a message that the file is in use, move on to File Locksmith or Safe Mode below.
Never take ownership of C:\Windows, C:\Program Files or other folders Windows manages, because changed permissions there can break updates and apps. To adjust access on a single folder from the Security tab instead, you can change file and folder permissions in Windows 11 without commands.

Delete a file or folder in Windows using Safe Mode
Safe Mode starts Windows with a minimal set of drivers and services, so startup apps, sync clients and most third-party software never get the chance to lock the file. Use it when a file is locked again every time Windows starts.
- Press Windows logo key + R, type msconfig in the Open box and select OK.
- Select the Boot tab, select the Safe boot check box under Boot options and select OK.
- Select Restart when Windows asks. The PC starts in Safe Mode.
- Open File Explorer, find the file or folder and delete it, or run the Command Prompt commands above.
- Press Windows logo key + R again, open msconfig, select the Boot tab and clear the Safe boot check box.
- Select OK and restart to return to normal mode.
You can also reach Safe Mode from the sign-in screen: select the shutdown button, then hold Shift while you select Restart, then choose Troubleshoot > Advanced options > Startup Settings > Restart and press 4 for Enable Safe Mode. Clear Safe boot in msconfig afterwards, or the PC keeps starting in Safe Mode.

Use a third-party program to force delete a file or folder in Windows
An unlocker tool shows which process holds the file and closes it for you. Microsoft's free PowerToys suite includes one, File Locksmith, which avoids installing an unknown unlocker from a download site. PowerToys runs on Windows 11 and on Windows 10 version 2004 or newer, and it is available from the Microsoft Store.
- Install Microsoft PowerToys from the Microsoft Store.
- Open PowerToys and turn on Enable File Locksmith.
- In File Explorer, right-click the locked file or folder. On Windows 11, select Show more options first.
- Select Unlock with File Locksmith. It lists every process using the file; for a folder it scans all files and subfolders.
- Select Restart as administrator if the list looks incomplete, because processes run by other users are hidden until you do.
- Select End task next to each process holding the file, after saving any work open in it.
- Delete the file or folder as usual.
From a terminal, PowerToys.FileLocksmith.CLI.exe "C:\Path\File.txt" lists the locking processes, and adding --kill ends them.

Can't delete a corrupted file in Windows? Run chkdsk
A file that Windows reports as corrupted and unreadable usually sits on a part of the drive with file system errors. chkdsk /f repairs those errors, after which the file can usually be deleted.
- Open Command Prompt as administrator.
- Type
chkdsk C: /fand press Enter, replacing C: with the drive that holds the file. - On the system drive, chkdsk cannot lock the volume while Windows runs and asks whether to check it the next time the system restarts. Type Y and press Enter.
- Restart the PC and let chkdsk finish before Windows loads. On a large drive this can take a long time.
- Sign in and delete the file or folder again.
Use chkdsk C: /r instead if you suspect bad sectors; it includes everything /f does and also locates bad sectors, so it takes longer.
Remove stubborn files and folders from your PC
Some folders refuse to delete because Windows or an installer still manages them. Removing them the supported way frees the space without damaging the system.
| Stubborn item | Why force deleting it is a bad idea | The supported way to remove it |
|---|---|---|
| Windows.old | It holds the previous Windows installation and many files are owned by the system | Use Disk Cleanup and its Clean up system files option, or the storage cleanup in Settings |
| An app's folder in Program Files | Deleting files leaves the app registered and its uninstaller broken | Uninstall the app from Settings > Apps or Control Panel > Programs and Features, then delete any leftover folder |
| Files in the OneDrive folder | OneDrive can restore or resync them | Delete them from the OneDrive folder or on the OneDrive website so the change syncs |
| Folders under C:\Windows | Windows needs them and protects them with system ownership | Leave them alone; repair Windows with DISM and SFC if something is wrong |
| A path longer than 260 characters | Many Windows tools stop at the 260-character MAX_PATH limit | Rename the parent folders to short names, then delete from the top folder |
You can remove the Windows.old folder through Disk Cleanup in a few minutes, with no ownership changes.
Folder still not empty after delete? List hidden files with dir /a
A folder that will not go away often still holds hidden or system files that File Explorer does not show. dir /a lists every file, including those.
- Open Command Prompt as administrator.
- Type
dir /a "C:\Path\Folder"and press Enter to list every item, including hidden and system files. - Clear the hidden and system attributes from the items it shows with
attrib -h -s "C:\Path\Folder\*" /s /d. - Run
rmdir /s /q "C:\Path\Folder"again. - Run
dir "C:\Path"and check that the folder name is gone from the list.
Force delete files and folders in Windows FAQ
How do I force delete a file that is open in another program?
Close the program that has the file open, or restart the PC to release the lock. If you cannot find the program, use PowerToys File Locksmith: right-click the file, select Unlock with File Locksmith, end the listed process and delete the file.
What is the command to force delete a folder in Windows?
In Command Prompt opened as administrator, run rmdir /s /q followed by the folder path in quotes. /s removes the folder with all its subfolders and files, and /q skips the confirmation prompt. In PowerShell, use Remove-Item with -Recurse and -Force.
How do I delete a folder that says I need administrator permission?
Take ownership first. In an elevated Command Prompt run takeown /f with the folder path and /a /r /d y, then icacls with /grant administrators:F /t, and delete the folder with rmdir /s /q. Do not do this to Windows system folders.
Why does Windows say the directory is not empty?
rmdir cannot remove a folder that still contains files, including hidden or system files you may not see. Add the /s switch to delete the whole tree, or list the hidden items with dir /a and clear their attributes with attrib -h -s.
Can I recover a file I force deleted?
Not from the Recycle Bin, because del, rmdir and Remove-Item delete directly. A File History backup or Microsoft's Windows File Recovery tool may get it back if little has been written to the drive since, so stop saving new files to it.
Does Safe Mode let me delete locked files?
Usually, yes. Safe Mode loads only essential drivers and services, so most startup apps and sync tools that lock files do not run. Boot into Safe Mode with msconfig, delete the item, then clear Safe boot and restart normally.
Is it safe to force delete files in Windows?
It is safe for your own files and leftover folders you recognise. It is not safe for anything under C:\Windows, Program Files or WindowsApps, because Windows and installed apps depend on them. Uninstall apps properly instead of deleting their folders.
If a command removed the wrong item, act quickly and recover deleted files with Windows File Recovery before new data overwrites it.





