Mar 16, 2010

Can’t Delete a File? Use the Command Prompt [How To]

Can’t Delete a File? Use the Command Prompt [How To]..[Tips &tricks brought to u by sasikumar]

 Have you ever experienced that windows won’t allow you to delete a file, presumably because some service or dll is still using it ? Even when you know for a fact that it’s not in use ? Or maybe you have tried to delete a folder, but you couldn’t because a “File in the selected folder is still in use by Windows” ?

Oh, I can hear you: “yes, but I use the “take ownership” function that I’ve added to my Context menu”. ALAS, Sometimes not even that will work – what then ? Do you have to Reboot your computer to be able to delete that file ?
Earlier, Harry had an article about the Command Prompt  and his top ten commands. One of those were the command we are looking to use now: DELETE (DEL).

The Command Prompt (cmd.exe) is what’s left of the old DOS (Disk Operating System) and some of us are old (shudders) enough to have actually used it as our main OS. Okay, enough of that.

Delete Troublesome files

This tutorial requires that you open the Command prompt as an Administrator and that you can access the folder from Windows.
  1. Click the Start-button and type CMD in the search field (Do NOT press Enter)
  2. When you see the program in the list, right-click on cmd.exe and choose Run as Administrator. This will open the Command Prompt Window with Administrative Privileges.
  3. In you Windows Explorer, open the folder you want to delete or remove a file from. Click on the Adress-field to reveal the true folder path.
  4. Highlight the path from the Colon (:) and to the end as shown here)




  1. Right-Click the Highlighted part, and choose Copy (or Press Ctrl+C)
  2. Go back to your Command-Window and type: CD\ (This will open the Root Folder)
  3. Now Type: CD\ and Paste in the path using Right-Click, Paste (Ctrl+V will NOT work).
    Like this: CD\testfolder
  4. To make sure you are in the correct folder you can type: DIR. This will show you the folder contents.











  1. To delete the file causing you problems, type: DEL[filename] /F /Q.
    Like this: DEL filename.dat /F /Q.
    The F means: Delete File even IF it’s reported as Read Only.
    The Q means: you don’t have to Confirm.
    If you want to delete all files in the folder, you can use wildcards instead of Filename
    like this: DEL *.* /F /Q

Delete Folder which Contains Troublesome File(s)

Sometimes you need to delete the problem file before you delete the folder, but this is what you do:
Follow steps 1 through 6 above then continue here:
In The Command-Window type:  RmDir /S /Q [Paste in path using Right-Click, Paste], Press Enter.
Like this: rmdir /S /Q c:\testfolder   












Folder and contents will be gone forever.          

No comments:

Post a Comment

Email subscribtions

Enter your email address:

Delivered by FeedBurner