Can’t Delete a File? Use Command Prompt

By Rich Robinson for Windows Guides

Can’t Delete a File? Use Command Prompt

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.
  • Type: explorer.exe.
  • Thanks to Jothe3inv and Johnny for bringing us this extra tip.


    Article continued here

    This excerpt appears with the permission of Windows Guides.

    Stop Responding to Threats.
    Prevent Them.

    Want to get monthly tips & tricks?

    Subscribe to our newsletter to get cybersecurity tips & tricks and stay up to date with the constantly evolving world of cybersecurity.

    Related Articles