Recently I faced a situation where I had to empty the recycle bin from Windows command line(CMD). After doing some search on this topic, I found that recycle bin is located on root folder of system drive. We can execute below command to clear all files and folders from recycle bin.
rmdir /s %systemdrive%\$Recycle.bin
To make it work we need to ruun command from elevated admin command prompt. Otherwise it throws error like below.
C:\Users\user1>rd /s %systemdrive%\$Recycle.bin C:\$Recycle.bin, Are you sure (Y/N)? y C:\$Recycle.bin\S-1-5-18 - Access is denied. C:\$Recycle.bin\S-1-5-~1 - Access is denied. Access is denied.
Cleanmgr is a GUI based utility but it has two interesting options /sageset and /sagerun. Using these two options we can clean up recycle bin from command prompt. You can find the steps below.
- First run the command ‘cleanmgr /sageset:1‘ either from command prompt or from Run window.
- Now in the clean manager window select Recycle bin and unselect every other category.
- Click on OK.
- Now onwards whenever you want to empty recycle bin, you can simply run the command ‘cleanmgr /sagerun:1‘ from windows command prompt.