Web Analytics


Windows Guides Feed

New to using the command prompt? Check out the Windows Command Prompt Beginner’s Guide

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 (read it here) 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.

[Edit]

As you can see from the comments below, some need to shut down the Windows Explorer (Not Internet Explorer) before succeeding to delete troublesome files. I recommend you first open the Command Prompt BEFORE shutting down Explorer even though it is possible to start it after. To shut down the Explorer window, you need to start Task Manager:

  1. Right Click the Taskbar, choose Task Manager.
  2. Open the Process Tab and locate Explorer in the list.
  3. Right Click the name Explorer.exe and choose “End Process“, confirm if asked
  4. All open explorer windows will close

NOTE!
All open programs will still be running (even task manager). You can still access the programs using ALT+TAB (or Windows + TAB).

Access the Command Prompt after shutting down Explorer

If you didn’t open the Command Prompt before shutting down Explorer, you may still access it by opening the Task Manager (which should still be running). Use ALT+TAB to flip through the running programs to open it.

  1. Click the File Menu
  2. Choose Run
  3. Type: cmd.exe
  4. Click OK

NOTE!
Should Task Manager by any chance be unavailable, you may open it by clicking CTRL+ALT+DEL, and choose Start Task Manager from the Menu.

Restart Task Manager

Once finished deleting your files you may restart the Explorer again lik this:

  1. Open Task Manager yet again,
  2. Choose Run from the File menu.
  3. Type: explorer.exe.

Thanks to Jothe3inv and Johnny for bringing us this extra tip.

 

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)
  5. Right-Click the Highlighted part, and choose Copy (or Press Ctrl+C)
  6. Go back to your Command-Window and type: CD\ (This will open the Root Folder)
  7. Now Type: CD\ and Paste in the path using Right-Click, Paste (Ctrl+V will NOT work).
    Like this: CD\testfolder
  8. To make sure you are in the correct folder you can type: DIR. This will show you the folder contents.
  9. 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:

  1. In The Command-Window type:  RmDir /S /Q [Paste in path using Right-Click, Paste], Press Enter.
    Like this: rmdir /S /Q c:\testfolder

  2. Folder and contents will be gone forever.


About Thomas

Computer geek from the age of 7, which amounts to 30 years of computer experience. From the early days (when every computer company had their own OS) of DOS, Windows 1.0 through Seven...

Free PC tips by email

Search Windows Guides




Comments

189 thoughts on “Can’t Delete a File? Use the Command Prompt [How To]”

  1. Tyrone Whiston says:

    Thank you so much for this brief, yet very helpful, tutorial. :)

  2. Brittanie Elizabeth Brockway says:

    Still said access denied. =/

  3. Just_some1_blind says:

    thanks a lot! old school solutions still help!

  4. Lol says:

    or just restart it!

    1. Igorsriga says:

      I suppose you never have other work happening when you want to delete something…moron…lol

  5. Pratik says:

    Gre8. It worked for me

  6. Beeplorizon00 says:

    OMG thx so much man!!!

  7. Fanoffans says:

    Thank you Thomas you are the man!:)

  8. Praveen Gupta says:

    execellent bro…

  9. Borzica says:

    says “access denied”… WTF its a video file… any other suggestions?

    1. Rich says:

      Restart in safe mode (usually F8 key as your computer boots) and delete the file.

  10. Pachko says:

    Thank you very much, that was very annoying folder, especially the (.) files. Thanks again!

  11. Shrikantnatikar says:

    who to remove the os in command  fromant 

  12. jurgen57 says:

    useless…i guess cmd is not that powerful anyways

  13. Ram88 says:

    Very helpful. Two things though 1) You don’t say what the /s does. 2) In the text you have “Like this: rmdir /S /Q c:testfolder” but in the screen shot you didn’t type the c: . Was able to delete subfolders by going to the folder dir first then leaving out the c: . Thanks for your help.

  14. Glwalkergl says:

    I can’t thank you enough for this! I would have lost all my university work if it wasn’t for this article.

  15. Rich says:

    Glad it worked Steve!

  16. Pankajthebest27 says:

    if any folder shows access is denied .you should follow these steps
    first open cmd in run
    1- type cd if the folder is in c: drive otherwise d: e: f: whatever else
    2-type there- cacls sanj /p everyone:f
    3- note that sanj in folder name here
    hope this will help you thanks

  17. Pankajthebest says:

    i liked this very much .thanks ——thanks!!!!!!!!!!!!

  18. Tazz Azmi says:

    it says INVALID switch what shall i do ?

  19. Tazz Azmi says:

    finally .. thanks i don’t have to actually include f/ q/ and the file is gone for good thanks a lot ..

  20. Sandeep Khandolta says:

    it worked like a charm .. i used tuneup utility and cc cleaner but nothing worked until i found this,,,,,  

    Tx……………………….;)  

  21. J Freeman2030 says:

    I got this message: system can not find the file specified.

    the file a very long name with 0 bytes, and it is located on desktop. Can not rename, move or delete. 

    1. Thomas says:

      Try to use the  “take ownership” trick first, then return here and try using the above  help. (http://www.mintywhite.com/windows-7/7security/uac-annoying-add-take-control-to-context-menu-in-vista/

  22. Rich says:

    Have you tried the same method in safe mode?

  23. Jason Winsor says:

    hmm, tried takeown and the security way, both don’t work . the takeown way says SUCCESS i still can’t delete it. and its a movie

  24. Jason says:

    please help I’ve tried everything on this page. could it be a virus or malicious 

  25. Arthur25 says:

    tried to delete outlook express folder no go it deletes it but upon restart files are back WTF if microsoft can make it so you cant change/delete/or replace files why dont they just make windows a self repairing OS every time you reboot the required files would repair them selves and no hacker could ever stay resident inside of any computer

  26. ClintJCL says:

    This is a good solution, but it is not the ultimate solution. Anyone experienced know this already. It’s very easy to see which files have another file open.

    In my case, nothing has this folder open. I still can’t delete it. Not even as Administrator. And it’s nothing to do with explorer.exe…

  27. Kitty says:

    its amazing experience & 
    ultimate solution .thanks a lot. 

  28. Ashish8lko says:

    result of doing this says access denied in cmd

    1. Rich says:

      Can you confirm you ran the command prompt as an administrator?

      1. Bbglas007 says:

        I tried this and got the same message running as admin.

  29. GeorgeButel says:

    “CMD does not support UNC paths as current directories” according to my Windows command prompts, being run as administrator, and even in an admin account.

    1. Rich says:

      Does this happen when you launch the command prompt or when you run the command? Assuming the second, perhaps you have \ (two back slashes) in your path somewhere?

  30. Rich says:

    Have you tried deleting in Safe Mode?

  31. Jimminy says:

    Thanks a million mate, that seems to have gotten rid of it…Never thought of going old school on it, with DOS. Cheers again

  32. 12 says:

    it says the path to the file, and the ” – Acess is denied”

  33. Mikee Reb says:

    for some reason when i try to delete the folder after i paste the path, it says in command prompt “The filename, directory name, or volume label syntax is incorrect”

  34. guest says:

    Great trick! Wonderfully explained! Thank you!!!

  35. Cupofjava2 says:

    It works!  Thank you!

  36. Juan Icaza says:

    Awesome! You’re a genius my friend! That non delete-able file was getting on my nerves. Thanks!!!

  37. bmcom says:

    Omg i love you! Thank you so much

  38. Charliejohnson says:

    still says acess denied in process of something

    1. Uvais says:

      Try in Safe mode

  39. KlingonOffTheStarboardBow says:

    Windows 7 will NOT let me delete a file in System 32/Drivers. It will NOT let me as user with Administrator rights to give full permissions in this folder. Internet stopped working and someone on the internet said replace the raspppoe.sys file, but I can’t delete that or indeed set the persmissions needed.

    I also can’t  create an account called “Administrator”. It tells me there is one already, but there isn’t – only file with my name and given administrator rights.

    Basically it’s crap, isn’t it? OH I can’t delete toe raspppoe.sys file even usuing the DOS prompt

    1. Uvais says:

      You need to Take Ownership..if you want to rename

      http://www.mintywhite.com/windows-7/7security/uac-annoying-add-take-control-to-context-menu-in-vista/ 

      You can’t create Admin acc because there is one already
      You need to Enable that Account 

      <<>> 

      Open CMD as Admin and Run this Command

      net user administrator /active:yes 

      and reboot..All done

  40. Blaze-420_saintz4mobb says:

    i like the guide.  it is great, it  helped me a few times before, but this time is different, i am trying to delete a file within a folder, i would delete the whole folder altogether if i could, but my computer freezes and stops responding as soon as i get anywhere near the file or folder i want to delete, for the part where you have to copy the folder address into cmd to delete it, i can’t do that because i cant even get into the folder without freezing. it feels like someone or something is inside my computer messing around, i tryed AVG but it reports no viruses or corrupt files, which i really don’t believe. my computer is running significantly slower since i downloaded this file that i now can’t delete, I have isolated the folder and file from anything else important.

  41. Felix Daniel Oviedo Liranzo says:

    Thank you!! I almost spent a week trying to erase those video files.  

  42. Khryz0420 says:

    thank you….

  43. Meechdaryl says:

    THANK YOU THANKYOU all day wretling with stupid MKV files easy and simple 

  44. Rmnhntr says:

    thanks soooooooooo much, u da man

  45. D Null15 says:

    The file I need to delete is on C: but my Command Prompt (CMD) opens in S:

    How do I delete it? I tried simply copying the file over to S: but it wouldn’t let me do that either. Please help, it’s driving me nuts!

    1. Rich says:

      Type c: on the command prompt

  46. Jane says:

    thank you so much, you helped me!!! :)

  47. thank u says:

    TY so f*cking much i was desperate, stupid file, tried everyting, but now finally YES THANK YOU SO MUCH

    1. Hachiko says:

      Will you please stop swearing? It has never done you any good!

  48. thank u says:

    I think just time rmdir /S /Q D:

    1. ThinkSkeptic says:

      That didn’t work for me, it still tried to find it in C:

  49. rajesh says:

    When i tried i got this, pleas help
    C:>rmdirsq
    C:Program FilesCommon FilesAppleMobile Device Support
    The system cannot find the path
    specified.
    The system cannot find the file
    specified.
    The system cannot find the path
    specified.
    The system cannot find the path
    specified.
    The system cannot find the file
    specified.

  50. Derek says:

    Thank you very much my friend. Like you, I ‘grew up’ with DOS, except that I was 20 years old at the time. I had cut and pasted the troublesome file into the C: root directory and had been trying to delete it using the cmd.exe prompt. It was your tip about running cmd.exe as administrator that made all the difference. I had no idea that this was an option. Really appreciate the post.

Comments are closed.


Computer tips in your inbox
Sign up for the Windows Guides newsletter to get PC tips and access to free Windows books (More details)

Enter your email address:
 

Popular Guides

See which sites have been visited on your PC (even if private browsing mode is used)

Create a Windows 7 System Repair Disc

Best Free Anti-malware

Hibernate vs. Sleep vs. Shut-Down

i3, i5, and i7; Dual, Quad, Hexa Core Processors. How to they Differ?

Intel's Ivy Bridge Processor: new Features

Submit Your Tip
Submit your computer tip to us; receive full credit for all published tips

Windows Guides on Facebook