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.


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

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

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


  • Nikki

    uhhh why we dont have a shorter version or sum -_ i cant delete a file and its 8 gb !

  • Troublesome..

    I’m trying to remove this damned winrar, but when i type /S /Q c:WinRAR it says I can’t delete it since it’s being used by another procces? Help ?

  • max

    it keep telling me access denied

  • LPHeadstrong

    THANK YOU! Some empty folder wouldn’t delete (rather it would through CMD but was always in Explorer). RMDIR worked anyway! Simple solution but thanks again!

  • sufian

    Thank you very mutch ^&^

  • adrian

    thank you o master! I’d never thought to stop explorer before and that cracked it! quite often I get weird files I can’t delete and I know I fix the permissions but no matter what Vista won’t let me delete them. thank you thank you thank you!

  • Tim Murphy

    How do I go about deleting troublesome files from an external drive??? I have tried this method and can’t get it to work???

    • webb123

      I suggest to use “LONG PATH TOOL” it is very useful for renaming the long file, deleting the error file etc…

  • Gemma

    Thank you so muchi used the cmd thing through administrator thanks

  • Maddy

    Awesome info to delete files as well as folders

  • Mitya

    thanks very much!!! worked perfectly deleted the troublesome folder easily)

  • brandy

    Thank you a LOT!!!! by the way, if you want to delete certain file , you dont need to access that directory, you can just type ”DEL C:Directoryfile.exe” and it will delete file.exe. :)

  • Feño

    Thanks, worked perfectly for me!

  • Kaki

    It says >>> Access is Denied .

  • Adrinn

    I tried using this method, but cmd kept saying Access is denied even though I run it as administrator. Any suggestions?

  • Steve Paul

    if it says you can’t delete the file because its being used by windows explorer, i found the easiest way to delete it is to follow the steps above, but before doing so, open task manager and keep it open. go to the processes tab. end the explorer.exe process. then in task manager click the file menu and click on new task. run cmd and follow the steps above. make sure u have the file name already on your clipboard before u start this if its a longer filename to make it easier. when you finish go back to task manager, click file, new task and type explorer. u should b good to go

  • thanks guys :)

  • still unable to delete the file. There are 2 “files” with a size of “0” with no file extension (.mp3) and I cannot delete them. When I try to delete them in windows or cmd.exe as admin it says file not found or cannot find this item. They were left after downloading a vid to mp3 via the web/youtube. Been there for months now – anyone have another option for a file that “really isnt there” ???????

  • Type D: at the command prompt to switch to the D drive.

  • tanxxx a lot!

  • Simone

    THANKYOU so much for this post. I had weird torrent files that would NOT go away. I couldn’t rename, delete, open or move them. After playing around with your instructions, I have success!
    ‘Rmdir’ didn’t work for me for every folder, but once the problem files were deleted, I opened explorer again and deleted the empty folders in explorer with no issue. I hope this helps someone else. Thanks again!

  • Thanx man my file is deleted without using command prompt I just End process explorer and open cmd after i restart explorer.exe from taskbar …..after file has deleted…(Windows vista).

  • Dybus

    It’s gone! Thank you so much!!!

  • gustech

    I deleted a .psd file using cmd with explorer off. Now the file owning program (photoshopelements) won’t run anymore.



  • Steven Kennedy

    It appears that DOS doesn’t handle file names that include spaces. Is there any way to get around that?

    • Steven, you can enclose the file name with double quotes. If you’re referencing the file with a path i.e. C:FolderFile Name.txt, be sure to put the whole path in quotes.

      • TheRandomGamer 1234

        My ass, it wont work!

  • PsychoMan

    WOW thanks man for this i got rid for a file that gave me alot of trobles

    thank you

  • fabulous007

    thank you so much for this brilliant advice! I was having such trouble deleting a video file, but this sorted out the problem in no time! very grateful indeed :)

  • o

    i still get access denied

  • doesnt work

  • DC

    Here’s an alternate method to opening the command prompt directly from the base folder that you’re performing the operations within. All you have to do is hold the shift key and right click within the whitespace of the base folder. The right-click context menu will then contain an option to open the command window directly within the folder, thus bypassing the need to open within the system partition and manually direct the prompt to your base folder. See the image attached.

  • DBoydNL

    Sucks when the instruction “DEL[filename] /F /Q” contains an error (space is missing after “DEL”, which forces you to retype the command (and read the example) to get it right. DOS has indeed been too long ago for me to recognize the mistake immediately. The devil’s in the details. Got it to work though (when I added a wild card for the non existent extension), thanks!

    • I updated the article and put a space in there :)

  • Amanda Lynn

    You just saved me so much trouble!!! I love you!!!

  • jay den

    Long path tool can be helpful on this situation

  • Mahmudur Rahman

    Thanks for your tips. I resolve my problems without shut window explorer. Thank you again. Its really work.

  • Dylan

    What if forler I wan’t to delete is not on local disc C, but in external disc G

    • Seneral

      I put a random disc in my drive and could access it with simply ” D: ” instead of ” CD ” just pick your discs path

  • Ellen Hanson

    del …. /F /Q doesn’t work if file reported as in use, Windows 7, it just just gives same error msg … Note: Unlocker works.

  • DLee

    Thanks very much, it works!!!

  • juliaop

    Long Path Tool is Very Easy solution For this problem.


  • shashi kant Gupta

    Try “Long Path Tool ” is also useful in situations where you see these error messages: Cannot read from source file or disk, there has been a sharing violation, cannot delete file or folder, the file name you specified is not valid or too long.

  • davehu

    I had this same experience and I’ve been using Long Path Tool for my files.Awesome tool.

  • Dave P

    the switches are /F and /Q —that’s where I was coming up short wiping .dlls and such from program directories that didn’t completely uninstall (do they ever?)

    Easy mnemonic: /F /Q: F&&& you. I’ll remember it forever. By the way, I still have my MS-DOS 5 manual.

  • eden

    Use Long Path Tool, Long Path Tool can simplify and probably end your
    problems in unlocking, managing and renaming files that appear to have a
    long filename.

  • ☠Kristina.Murphy☠

    worked amazing thank you, the deleting wild card thing is what did the trick.
    windows.old has been on my computer since 2014 even after several reformats.
    glad it is gone now. again thank you.

  • Ronald Carl

    I tried Long Path Tool, it worked great for me.

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