Force Delete File or Folder using Command Prompt on Windows

F

The Command prompt is one of the most basic element of Windows. When everything else fails, it is the command prompt which will ultimately come to your help. One of these things where the command prompt might be your ultimate hope, is when your computer gets infected and once you’ve cleaned it, no matter how long you try, there remain many files and folders that would simply refuse to be deleted.
In a situation like this, it becomes extremely important to delete these files as there will be a chance of the infection recurring. So how would you delete such files on windows which cannot be deleted with the windows explorer.
Well, you can make use of an free tool for windows called Unlocker and it will help you to delete any undeletable files and folders from windows with ease.
Alternatively you can even use the command prompt on windows to delete files which are refusing to be deleted via the windows explorer. However before we proceed ahead, i would only advise you to use this method if you are familiar with the command prompt. If the instructions are not followed properly, you might accidentally delete something else.
Here’s how you can use the command prompt on windows to forcefully delete files and folders.

How to Delete a single file using the Command Prompt on Windows

  • Step 1: Run the Command prompt on windows.
  • Step 2: You will need to type the following into the command line and press enter.

DEL /F /Q /A <File Path>

Here the /F parameter stands or force deletion of files, /Q parameter ensures the Forces deletion of read-only files, /A parameter will select only the files with the ready for archiving attribute, Finally you can replace <File path> with the path of the file or folder.
For example: Type in the following into the command prompt and press enter.

DEL /F /Q /A C:\Users\Lovejeet\Desktop\infected.txt

Force-Delete-An-File-Using-Command-Prompt-on-Windows
If the file gets deleted successfully,  then you won’t receive any error.

How to Delete a Folder using the Command Prompt on Windows

  • Step 1: Run the Command prompt on windows.
  • Step 2: You will need to type the following into the command line.

RD /S /Q <Path of the Folder>

Here RD stands for Remove Directory, /S deletes all subfolder and files, /Q Deletes directories without confirmation.
For example: Type in the following into the command line and press enter.

RD /S /Q C:\Users\Lovejeet\Desktop\Folder

Force-Delete-An-Folder-Using-Command-Prompt-on-Windows
If the folder gets deleted successfully,  then you won’t receive any error.
 
 

About the author

lovejeet

15 Comments

By lovejeet

lovejeet

Get in touch

Quickly communicate covalent niche markets for maintainable sources. Collaboratively harness resource sucking experiences whereas cost effective meta-services.