Sometimes it may happen is that you may try to delete something from your computer but won’t be able to do it and error message will pop-up stating- “Can’t delete; folder is in use by Explorer.exe“. You will not be able to remove the directory completely unless you stop the explorer process first. Follow these simple process first to stop explorer process and then delete the file from Command Prompt.
Fix-1 Delete the folder using CMD command-
End the Explorer process and then delete the folder from Command Prompt.
1. First, press Windows key+E to open File Explorer window on your computer.
2. In File Explorer window, navigate to the problematic folder.
3. Note down the file path from the address bar.
4. Search “cmd” in Search box beside Windows icon .
5. Then, right click on “Command Prompt” in the elevated search result and choose “Run as administrator“.
Command Prompt with administrative rights will be opened.
6. Minimize the Command Prompt window. We will use it later.
7. Now, Press Windows key+R to open Run window.
8. In Run window, type or copy-paste “resmon” and hit Enter to open Resource Monitor.
9. On the right hand side of Resource Monitor window, in ‘Associated Handles‘ panel, type the name of the problematic file (For us it is -“7-zip“).
10. Now, right click on “Explorer.exe” and then click on “End Process“.
Explorer process will be ended. You will not be able to use it to delete the folder.
12. Now, maximize Command Prompt window.
13. Next, copy this command and paste it in Command Prompt window and modify it and then hit Enter to execute it.
rd /s <folder path>
[NOTE– Replace the <folder path> with the location of the problematic folder you noted. For us the command will look like something like this- “rd /s C:\Program Files\7-Zip“.]
That should remove the folder from your computer.
Reboot your computer.
Fix-2 Use Process Explorer-
Process Explorer is a tool provided by Microsoft which allows a deeper look into the detection of any associated process preventing any particular service on your computer.
1. Download Process Explorer on your computer.
2. After downloading the zip file, go to the downloaded location.
3. Extract the downloaded “ProcessExplorer” zip file in a location of your choice.
4. Now, go to the extraction site on your computer.
5.Now, double click on “procexp64” to run it on your computer (In case if you are using 32-bit Windows 10, you should run “procexp” on your computer).
6. In Process Explorer window, click on “Find” on the menu bar and then click on “Find Handle or DLL…“.
7. In Process Explorer Search window, enter the name of the problematic file beside ‘Handle or DLL substring:‘. (For us, it is “7-zip“).
8. Then, click on “Search” just beside the search box.
9. Wait for a while as the Process Explorer will list the processes which are using the file.
10. When the search is complete, click on the process in the process tab. The following process will be highlighted in Process Explorer window.
11. In Process Explorer window, right click on the “explorer.exe” process and then click on “Close handle” to close the process on your computer.
Once you have closed the process, close Process Explorer window.
Again, try to delete the file/ folder again using cmd . This time it will be deleted without any further issue.
Your problem will be solved.
Sambit is a Mechanical Engineer By qualification who loves to write about Windows 10 and solutions to weirdest possible problems.