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?
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.Sign up to join this community
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..)
I found another way. You can also solve it by restarting
However this does not work if it is locked by another process other than explorer.exe.
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.
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 follow these steps to find which program is locking folder:
wmic process > processes.txt. This will create an output file
processes.txtwith details of all process running.
processes.txtin a text editor.
TaskManageror using command
TaskKill /PID <pid>. Where
<pid>is PID found at step #3.
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.
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'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.
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
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
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.