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 run the command from elevated admin command prompt. Otherwise it throws error like the one below.
C:Usersuser1>rd /s %systemdrive%$Recycle.bin C:$Recycle.bin, Are you sure (Y/N)? y C:$Recycle.binS-1-5-18 - Access is denied. C:$Recycle.binS-1-5-~1 - Access is denied. Access is denied.
Alternative option
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.
What about this:
rd /s %systemdrive%\$Recycle.bin
del /s /q %systemdrive%\$Recycle.bin
pause
Awesome, That works.
Awesome!
Worked like a charm, thanks !
works great thx
I had a recycling bin contained millions of files, and used this code which worked perfect:
del /s /q %systemdrive%\$Recycle.bin
As the the author advices, first open an elevated command prompt. This instruction was very useful:
start del /s /q %systemdrive%\$Recycle.bin
pause
the above command is it delete files from recycle bin or everything fromC drive
how about other drives ?
Hi, Is there any command to clear a recycle bin on different drives on the same computer? (For Ex: D drive or E Drive)
like Mahesh asked. I need to please know.
Mahesh
Hi, Is there any command to clear a recycle bin on different drives on the same computer? (For Ex: D drive or E Drive)
del /s /q F:\$Recycle.bin
(You can change “F:” to whatever drive letter you want to access)
I am trying to copy all files to another drive. I need to preserve date/time stamps (filenaming conventions). I was able to do this initially, but I think the Recycle Bin became corrupted. Here is the error I am getting:
C:\Users\SF>ROBOCOPY G: F:\ /E
——————————————————————————-
ROBOCOPY :: Robust File Copy for Windows
——————————————————————————-
Started : Sunday, May 15, 2022 1:09:58 PM
Source : G:\
Dest : F:\
Files : *.*
Options : *.* /S /E /DCOPY:DA /COPY:DAT /R:1000000 /W:30
——————————————————————————
1 G:\
*EXTRA Dir -1 F:\COPY\
*EXTRA Dir -1 F:\Review\
*EXTRA Dir -1 F:\Review_and_CLean\
*EXTRA Dir -1 F:\[KEEP]\
0 G:\$RECYCLE.BIN\
2022/05/15 13:09:58 ERROR 5 (0x00000005) Accessing Destination Directory F:\$RECYCLE.BIN\
Access is denied.
Waiting 30 seconds…
C:\Users\Admin>rmdir /s %systemdrive%\$Recycle.bin
C:\$Recycle.bin, 是否确认(Y/N)? y
C:\$Recycle.bin\S-1-5-18 – 拒绝访问。
C:\$Recycle.bin\S-1-5-~1 – 拒绝访问。
C:\$Recycle.bin\S-1-5-21-473612265-2691535141-3666490896-1001 – 拒绝访问。
拒绝访问。