129

Sometimes when I'm working in Windows I'll get this prompt when I try to delete a directory:

Folder In Use
The action can't be completed because the folder is open in another program
Close the folder and try again.

However, the folder isn't "in use" at all, and I don't have it open. So how can I delete it short of rebooting?

18 Answers 18

80

This answer is old, but seems to still get traffic. As noted below, there is a built in tool in Windows now:

Start → All Programs → Accessories → System Tools → Resource Monitor (or Run resmon.exe)

You can get more info in the answers below this one. The rest of this answer is no longer as relevant.


Process Explorer from Sysinternals will let you search through the handles and DLLs. Search for the directory and find out which process is "using" the folder.

From there, you have the ability to either shut down that process, or just close that particular file handle. Be sure about what you're doing when working with the file handle directly, and make sure it's not being used by some important process.

  • 4
    But how I find directory which is used by process? – Johnny_D Sep 11 '13 at 10:14
  • 2
    Use Ctrl-F and enter the name of the folder above the one you are trying to delete. – MikeMurko May 6 '14 at 20:58
  • 4
    There is now a native GUI for Windows, see my answer below. – bcorso Jun 27 '14 at 20:48
  • 3
    *Native GUI /built into/ Windows (Resource Monitor) see below. – Jamie Pate Nov 7 '14 at 5:43
  • In my case, Process Explorer was not able to find the handle, but the Resource Monitor (see other answer) was capable. – Bart Verkoeijen Mar 1 '16 at 6:34
174

There's a native GUI for Windows:

Start>>All Programs>>Accessories>>System Tools>>Resource Monitor (or Run resmon.exe)

You can search for the "Associated Handles" using the searchbox (circled in red), and right click the process you want to end.


As an example, in the image below I could not delete my Eclipse directory. Searching for the Eclipse associated handles showed that the adb.exe had a handle to the directory. After ending the adb process, I could then delete the Eclipse directory.

enter image description here

  • 5
    This trick highlighted the process that was giving me grief :) – Pure.Krome Aug 28 '14 at 11:32
  • 2
    Resource Monitor requires administrator credentials. – Air Nov 23 '15 at 19:09
  • I have a locked folder on my desktop that resource monitor does not list as being used. Oh well. – sirdank Dec 11 '15 at 17:06
  • locked? This is to solve the particular error in the question, i.e. "the folder is open in another program." Is this your situation? – bcorso Dec 11 '15 at 17:39
  • 1
    Solved the problem for me. – RubenGeert Apr 24 '16 at 8:27
7

Unlocker and WhoLockMe don't work on 64-bit Windows. I use LockHunter.

  • 2
    Unlocker comes for 64-bit system. – avirk Apr 14 '13 at 1:58
  • lockhunter found the locking process for me that both ProcExp and ResMon could not find. – Clever Human Jan 24 '18 at 14:17
7

When using tools that forces file handles closed (like the previously-mentioned Unlocker), keep in mind that doing so might cause serious problems. (See this article by Raymond Chen.) Make sure you know which applications are using the file and that none of them are doing anything important.

It's safer to try shutting down the applications first instead of just forcing the handle closed.

  • Way good article. Important read. – Pacerier Jun 8 '15 at 20:17
6

This REG script will give you a "View Handles" right click context menu item which will invoke the Sysinternals handle utility to see all open handles to the file or folder that you right clicked on.

Put handle.exe from Sysinternals into a location that is accessible from your path.

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\AllFilesystemObjects\shell\Handle]
@="View &Handles"

[HKEY_CLASSES_ROOT\AllFilesystemObjects\shell\Handle\command]
@="cmd.exe /k handle -a -u \"%1\""
  • Why not just use the UI version ProcessExplorer? – Pacerier Jun 8 '15 at 20:19
5

I've had that happen to. Sometimes I can resolve the issue by deleting the contents first, then the folder(empty).

  • Yes - it worked for me! – TigerTiger Jan 21 '13 at 13:04
  • @Wbdvlpr, @ kpoehls, Why would this work? I think it's just a myth and you happen to be lucky. – Pacerier Jun 8 '15 at 20:20
3

The quickest and simplest approach is to use Handle, as mentioned by slolife, rather than using Process Explorer. They're both from Mark Russinovich @ Microsoft.

Don't be surprised to find that explorer.exe is the culprit, as I did today. Apparently there is an official way to restart explorer.exe, but I seem to be getting away with killing it and starting it back up again it in Task Manager.

2

When I was on XP I used WhoLockMe to find out what programs had files open and locked. The most recent version I could find doesn't mention Vista, but it'd be worth a shot.

Sometimes, you can delete it from the inside out manually. Just navigate all the way down in the hierarchy, delete all files, move up a directory, and repeat. Not sure why Windows can't do this itself, but it sometimes works for me.

2

If by “not in use”, you mean there are no open handles to it, then make sure that the Application Experience service is not disabled. If so, set it to manual:

Run dialog (or command prompt):

  sc config AeLookupSvc start= demand
2

I use Handle from SysInternals (now Microsoft). You can type in part of the folder name to see which process has a handle on that folder and then kill the handle.

handle64.exe -nobanner "<path>"

For example:

command output from commandline

Like others have mentioned, killing the handle can cause serious problems.

1

In order to delete a folder/program that says you can't delete it because is open somewhere else.

  • Click start button
  • Type Taskmgr
  • In the new window that opened, under process tab, look for the folder/program you're trying to delete.
  • Right click it and End Task
  • Go back to the folder/program location and you should be able to delete it now
0

Try Ctrl + Shift + Esc > "programs", then right click the one you want to deactivate and choose deactivate. Then delete it again!

(My OS is in Swedish so the translations might not be exactly the same! but you get it!)

0

I've had the same problem with a memory flash (16 gb - irrelevant probably) and it wouldn't let me delete a folder. I tried every -freaking- solution found on internet (hiding thumbnails, deleting the folder from the cmd prompt with explorer.exe shut down, everything..) and nothing worked. What made it work? Well, this:

  1. Select all the files inside the folder
  2. Right click on them and select "Cut"
  3. Go back to the root folder
  4. Paste them
  5. Delete them

That worked just fine for me. Hope I helped. :-)

0

Had a file docs.zip in use by WinSCP.

  1. I created a new file using same name docs.zip
  2. Pasted over existing docs.zip and the old file got replaced by new same named file.
  3. Then I deleted the newly copied file docs.zip all together.

Good Luck

0

So there are already some good answers, but I'm going to contribute something new, which is what I used to resolve this same issue earlier today.

I used Python. I know, I know, it's not native to Windows, but it's very a very common utility for sysadmins, developers, and super users, and you can knock this out with a simple oneliner:

from shutil import rmtree; rmtree('C:\path\to\folder')

...bingo bango.

-1

oft times the handle that is locked is internet explorer, i either close it in task manager, then delete the file or folder or close explorer...often a folder has a txt file that is open and that will be the handle that won't let u delete folders/files...just close the txt file and then u should be fine, u can now delete ur folder.

  • Why would IE lock local files and why .txt? – gronostaj Aug 25 '13 at 14:06
-3

go into the folder all the way down to the file or files being executed. when you try to delete this file it will give you what process it is running . write that down, then go to the task manager and end that process .. after that you can delete the folder.

-3
  1. Find the file that you want to delete.

  2. Rename it to anything you like.

  3. Delete it.

  • 2
    This answer will not work. If a file or directory is use you can't rename it. – DavidPostill Apr 2 '16 at 6:49

protected by bwDraco Jul 2 '17 at 11:28

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.