I try to delete an empty folder, but I can't because the windows dialog says it is used at the moment.

How can a empty folder be used?? How can I solve this, without having to restart the computer or log off?

  • 6
    Your going to need to restart your system to delete the folder. You will have to determine which process is preventing the deletion of the folder.
    – Ramhound
    Commented Jun 21, 2018 at 11:02
  • 30
    It's always worth a quick check to see if you have a shell (Cmd, Bash, etc) running with the folder as its current directory. This is the usual reason that an empty folder is flagged as in use.
    – AFH
    Commented Jun 21, 2018 at 12:04
  • 18
    <rant>The only real solution is to reboot. Ideally, into Linux as I did a few years ago. This solved the problem permanently.</rant>
    – maaartinus
    Commented Jun 21, 2018 at 21:01
  • 3
    IObit Unlocker: "Never Worry about 'Cannot Delete Files' on Your PC" ... or the equivalent. That answer sounds too much like work.
    – Mazura
    Commented Jun 22, 2018 at 0:53
  • 7
    Glad to know this is still an issue 8 years later
    – txtechhelp
    Commented Jun 22, 2018 at 6:58

10 Answers 10


You will need to use Microsoft's Process Explorer (just an exe): https://docs.microsoft.com/en-us/sysinternals/downloads/process-explorer

It will let you know which app is handling that folder and you will also be able to kill that handle.

Find -> Find handle -> search for folder's name (will take a while..)

Visual tutorial: enter image description here

  • 5
    Or use the handle.exe utility (also on the sysinternals site) for a command line solution.
    – ErikE
    Commented Jun 21, 2018 at 16:22
  • 10
    This absolutely works. Only drawback is: You find software running (as services) on your machine that are holding those handles for seemingly no good reason and it just leaves you frustrated that relatively useless stuff is so invasive and written so badly... (though once you think about it, it makes sense …)
    – davidbak
    Commented Jun 21, 2018 at 16:40
  • 3
    Alternatively, before going through all that, you might want to try rebooting and try again. If it is still locked, then something that gets launched at boot or log on time is grabbing it when it launches.
    – jpmc26
    Commented Jun 21, 2018 at 17:35
  • 18
    Do note that forcing handles closed can cause data corruption in certain circumstances. Explorer should handle it fine, but many programs may not Commented Jun 21, 2018 at 18:16
  • 5
    I'd recommend killing the process that owns the handle instead of closing the handle.. You should think twice either way... Commented Jun 22, 2018 at 17:26

I found another way. You can also solve it by restarting explorer.exe.

However, this does not work if it is locked by another process other than explorer.exe.

You can do this from Task Manager. Open task manager from taskbar or with Ctrl+Shft+Esc, then if you don't have a windows explorer tab open, open one.

In Task Manager, when you select other apps, the action button says "Quit", but if you select file explorer, the button says "Restart".

  • 6
    This simple trick works for me most of the time.
    – NVZ
    Commented Jun 21, 2018 at 12:49
  • 37
    No. It will only solve the problem if the folder is locked by explorer. Commented Jun 21, 2018 at 16:53
  • 7
    And your shell may not even be explorer.exe Commented Jun 21, 2018 at 20:26
  • Remember to close shell and open another instance Commented Jun 1, 2020 at 20:57

You can follow these steps to find which program is locking folder:

  1. Run following command on command prompt wmic process > processes.txt. This will create an output file processes.txt with details of all process running.
  2. Open file in processes.txt in a text editor.
  3. Search for locked folder name. You will get Name and PID or process accessing folder.
  4. Kill process using TaskManager or using command TaskKill /PID <pid>. Where <pid> is PID found at step #3.
  • I wish this worked. It didn't. CD C:\ - md temp - cd temp - md utemp - cd utemp - notepad - cd .. - rd utemp (failed due to notepad) - wmic process > processes.txt - the result ing processes.txt did not contain "utemp",
    – TOOGAM
    Commented Jun 24, 2018 at 9:18
  • @TOOGAM Thanks for pointing that out. I am surprised to see that it actually happened with Notepad. Tested Notepad++ too and was able to delete folder without any issue. +1 for accepted answer.
    – Sandeep
    Commented Jun 24, 2018 at 10:37

Sysinternals suite has already been mentioned, but ProcessExplorer is actually the wrong tool. movefile is what you want. Killing the process that has the directory open may work, but it is not a good (or safe) approach.

With movefile you can, well... move files (directories are files!) on the next reboot. Moving a file to no destination, i.e. "" schedules deletion on next reboot. Note that it needs to be run from an elevated prompt (otherwise you get Error 5 trying to schedule boot-time deletes).


You can forcefully terminate the process responsible for "locking" folder given the process ID is known, and any good process killer can do that without having to restart the system.

Alternatively with a GUI you could use Iobit unlocker to unlock the folder, and thus delete the folder afterward. Drag the target folder on the iobit interface then, on the scrollbar beside select unlock and delete.

Sample screenshot

  • 1
    Disclaimer!! no affiliation to the software, but just happen to be an easy GUI based way to do it Commented Jun 21, 2018 at 12:14
  • 3
    Using this software might cause the process that has the lock on the file/folder to crash or become unstable. I would suggest using datester's answer
    – Cfinley
    Commented Jun 21, 2018 at 17:13
  • 1
    Windows may reuse the handle for another file, which can lead to really nasty stuff: the application that locked the file will now unknowingly work on another file, which can potentially have disastrous effects.
    – gronostaj
    Commented Jun 22, 2018 at 8:42
  • 1
    Ok fair enough to those who insist this method is bad, but trust me it still gets the job done for me without even breaking a sweat. Besides there are just too many ways to "kill this cat" Commented Jun 22, 2018 at 10:22
  • 1
    @xavier_fakerat You either didn't understand the problem that gronostaj lined out or you have a very cavalier attitude towards your files.
    – Voo
    Commented Jun 23, 2018 at 9:36

I also had this problem before, and I solved it by going to the Git Bash, and using rm -rf my-directory.

I have no idea why it worked tho, maybe Git bash has more right than the windows command.

If you don't know Git, you can download it by typping 'Git' on Google, install it and then just right click on your explorer, where the directory is, and click on 'Git bash here'.

  • I am using git bash, probably this was actually the cause.
    – Black
    Commented Jun 25, 2018 at 8:27

I've actually noticed in the past that even with hidden files on and all the bells and whistles saying to show all files that certain programs would still have files that if saved with them were completely invisible in explorer. That's likely the case here. What I would do is go into whatever programs you were using this folder with and go to open file (if applicable) and see what is actually in the file in that view. There might be a lot of junk windows seems intent on hiding from you.


Restarting windows explorer did the trick for me. Just go to task manager and restart explorer.


I've had this problem before, years ago when I used a website's automatic convert/download to change a page's html into a txt file download. The way Windows deals with the naming of files made it so that the quotations in the title changed the filetype to whatever was after the quotes, and made it undeletable. The solution I found was also described as being able to delete folders, so it should help you too.

First, open command prompt with admin privileges. Say that the folder I want to delete is in C:\Users\XXXXXX\Downloads

Make sure to include spaces wherever I make them, or else it won't work

Type in the command:

cd /d C:\Users\XXXXXX\Downloads

Next type:

dir /x

That will show you a list of all items within Downloads, with the date/time created followed by a ( <DIR> ) if a folder / a ( 0 ) if a file, the name in a shortened format, and then the full name.

Find the shortened name of the folder you want to delete and then type it exactly as shown in the list - capitalized, numbers, tildes, whatever (without the labeling 0 if a file) - minus the brackets I include here in the example:

rmdir /q /s [SHORTNAMEHERE]

And that's it! If you want to delete a file, just change rmdir to erase, and you're good! Just make sure that the folder you want to delete is actually empty and has nothing important in it first.


I launched a powershell process from a folder via win cmd.
After powershell finished, I cd .. in win CMD but rd /q /s gave error: open in another process
I get same error when manually delete folder in explorer window, even if it was empty.

wmic process revealed that powershell.exe could be locking the folder, even though powershell had finished the task & powershell window had closed. This was confirmed by tasklist

I then taskkill /im powershell.exe, after which the folder could be deleted.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .