How to delete Undeletable files using cmd?

Deleting files that seem undeletable can be a frustrating experience for many computer users. Sometimes files become corrupted or stuck, preventing you from removing them through normal methods. Thankfully, there are some simple tricks using the Windows command prompt that can force delete just about any file or folder on your system.

What are Undeletable Files?

Undeletable files are those that cannot be removed through the standard Windows delete functions. When you try to delete them through Windows Explorer or the Recycle Bin, you may get an error message saying the file is in use, invalid, or that access is denied. Some common causes of undeletable files include:

  • File corruption – Damaged file structures can prevent proper deletion.
  • Applications still using the file – Files locked by apps can’t be deleted until closed.
  • Insufficient permissions – Administrative rights are often needed to force delete.
  • Unknown system errors – Bugs and glitches can sometimes cause delete issues.

Regardless of what causes a file to become undeletable, using the command prompt provides you with the power to force delete it. The cmd commands can override permissions, close file handles, and skip straight to erasing file data from the disk.

Accessing the Command Prompt

The first step is to open the Windows command prompt. This grants you access to use the delete commands. Here are a few ways to open it:

  • Press Windows Key + X and select “Windows Terminal” or “Command Prompt”
  • Search for “cmd” in the Windows start menu and click on “Command Prompt”
  • Open the Start menu and browse to Windows System > Command Prompt
  • Shift + right click in an empty space within a folder and select “Open command window here”

You’ll want to make sure you open the command prompt with Administrator rights. This allows the delete commands to work with full permissions. If the prompt opens without Admin, close it and reopen as an Administrator.

Delete a File using DEL

The DEL command is the basic way to delete files and folders using the Windows command line. DEL stands for delete. Here is the syntax:

DEL [drive:][path]filename

For example, to delete a file named “untitled.txt” on your desktop, you would use:

DEL C:\Users\[user]\Desktop\untitled.txt

DEL is simple to use but cannot bypass some of the protections that undeletable files have. For that we need to use some more advanced options.

Delete Files using RD

The RD or RMDIR command is used to remove directories (folders). But it can also force delete files by deleting the directory structure around them. Here is the syntax:

RD [drive:][path]

For example, to delete a folder called “temp” on your C drive you would use:

RD C:\temp

To remove an undeletable file like C:\file.txt you could do:

RD C:\file.txt

This will delete the file by removing the folder structure containing it. RD is often effective at removing undeletable files when standard DEL commands fail.

Using Erase Commands

Several command line tools also have special “erase” options that can force delete files. These perform low-level disk operations to completely scrub file data. Here are some of the common erase commands:

  • ERASE – The ERASE command accepts a path and filename to permanently erase.
  • cipher /w – The cipher tool with /w flag scrubs file data for secure deletion.
  • sdelete – Sdelete has several options like -p for physical drive erase.

For example, to securely erase C:\File.txt you could use:

cipher /w:C:\File.txt

These erase tools can penetrate deep and delete persistent undeletable files when other options fail.

Unlocking Files with Unlocker

Unlocker is a free utility that can unlock files Windows thinks are in use. Fixing file locks can allow normal deletion. Download and install Unlocker, then right-click a locked file and select Unlocker.

It will present deletion options like Delete and Permanently Delete. For heavily locked undeletable files, Permanently Delete can force removal. Unlocker provides an easy GUI for file unlocking.


Following these command line deletion techniques allows removing just about any undeletable file in Windows. The DEL, RD, ERASE, and Unlocker utilities give you the tools to handle deletion no matter the circumstances. Some key takeaways include:

  • Open Command Prompt as Administrator to get full permissions.
  • Use DEL to delete simple files and RD to remove enclosing folders.
  • Cipher, Sdelete and ERASE erase at the disk level.
  • Unlocker can release file locks before standard deletion.

Stuck with an important file you just can’t delete? Don’t give up hope. With the robust delete capabilities of the Windows command line, you can force removal and reclaim your disk space.

Frequently Asked Questions

Why do some files become undeletable?

Files can become undeletable for several reasons: corruption, being locked by applications, insufficient user permissions, and general software bugs. The file system losing track of the file’s location can also render it undeletable.

Can the Recycle Bin delete undeletable files?

No, the Windows Recycle Bin does not have the capabilities to force delete undeletable files. It uses the standard file deletion functions which will fail on corrupted or locked files. The command prompt tools are required.

Do I need special software to use these commands?

No, all the mentioned commands like DEL, RD, ERASE, and Unlocker work on any standard Windows machine. They are built-in commands or free utilities available for download. No special software is needed.

What if I delete the wrong file by accident?

It is always best to double check the filename and path before performing destructive deletion commands. However, most deleted files can be recovered using free tools like Recuva and Testdisk. Just avoid writing new data to the drive until recovery is complete.

Can these commands remove viruses and malware?

Yes, the erase style deletion techniques are effective at removing viruses, trojans, and other malware. The low-level drive wiping performed by tools like Cipher and Sdelete will destroy all trace of malicious software.

Is there an easier way to force delete files?

Using the command line provides access to the most powerful file deletion capabilities in Windows. However, some third party apps like Unlocker do provide simpler GUIs. But ultimately robust undeletable file removal relies on cmd tools.

Example File Deletion Commands

Command Description
DEL C:\File.txt Standard file deletion
RD C:\MyFolder Remove folder and contents
ERASE C:\Document.pdf Force delete file from disk
cipher /w:D:\Data.xls Securely wipe file data
sdelete -p C:\ Full physical drive erase