Empty recycle bin command line

I’ve run into the situation before where I’ve needed to empty the Recycle Bin for all users on a multi-user computer. After doing a lot of searching I realized that the only real way to empty the Recycle Bin for all users on a computer (without logging in as each user) is to completely remove the Recycle Bin directory from the PC. This will delete all files in the Recycle Bin for all users, and then Windows will just recreate the directory when it is needed again.

So how do you do it? You need to open a command prompt window as an administrator, and then the directory you need to remove varies depending on the OS you’re working with:

  • For Windows 7 or Server 2008 run this command from the command prompt:
    • rd /s c:\$Recycle.Bin
  • For Windows XP or Server 2003 run this command from the command prompt:
    • rd /s c:\recycler

Note: These commands reference the “c:\” drive. Each drive keeps its own Recycle Bin so you’ll need to run this for each drive letter that you want to empty.

After running the command you may notice that the Recycle Bin icon may not refresh immediately to reflect that it is empty. This is because you’re using a non-standard procedure to empty the Recycle Bin, but if you open it up the icon will refresh and you should see that there are no files in there.

There Are 19 Comments

  1. Just one advise: apparently if you run the command on Windows Power Shell, even with administrator privileges, it does not work. The message below is returned:

    Remove-Item : A positional parameter cannot be found that accepts argument ‘d:\.Bin’.
    At line:1 char:3
    + rd <<<< /s d:\$Recycle.Bin
    + CategoryInfo : InvalidArgument: (:) [Remove-Item], ParameterBindingException
    + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.RemoveItemCommand

    Using normal DOS prompt works normally as said by Ryan.

  2. Note that if someone mistypes this by putting a space after either the colon or backslash, most of the drive will be deleted, ending with lots of applications crashing then either a BSOD or reboot, followed by “NTLDR is missing”.

    I just tried this in a VM :)

    • To avoid this, the best way would be to create a .bat file with the command and run it when necessary.

  3. In PowerShell, the “$” character is used to refer to a variable. To use it as-is, you will need to escape it with a backtick (`).

    If you’re in the root of C: and type “dir $Recycle.bin -Force”, you’ll actually get a listing of the files and folders in the root of C:, as you most probably don’t have a PowerShell variable “Recycle.bin”, so the command is interpreted as “dir -Force”.

    Typing “dir `$Recycle.bin -Force”, however, will show you the contents of the recycle bin.

  4. Great tip. I’ve got a server with about 7 accounts on it and can see this being very useful. Thanks!

  5. thank u very much … i have been desperately looking for it

  6. This is how you can do it with PowerShell (runas administrator needed)
    PS C:\> ls ‘$recycle.bin’ -Force | Remove-Item -Force

  7. I try running it in cmd, and get the error
    C:\$Recycle.Bin\S-7236~1 – Access is denied.

    Then I try it in powershell (first time using PS) and get the same errors as noted in the first post.

    I am administrator, and am using Vista Home Basic.

    Any ideas on how to get this to work?

    Thanks

  8. Xavier, even if you are logged in with an administrator account, right-click and use ‘run as administrator’ to launch cmd. You have to use ‘run as administrator’ to get all the privileges because of UAC (User Account Control)

  9. I don’t like the risk of a typo and loosing some files and directories. Why not use windows command %SystemRoot%\system32\cleanmgr.exe which does the same and more !?

    • There is no Disk Cleanup in server 2008. you don’t risk typo if you write a batch file and check it before you run it, Then make it read only.

      OK…

  10. Cleanmgr ? I have seen it, but before I use it I want to know what is is doing.

    A simple BatchFile on my machine is much more easy for remove the $Recycle.bin.
    Thanks to the author I use now…

    @echo off
    echo J | rd /s C:\$Recycle.bin
    echo J | rd /s D:\$Recycle.bin
    echo J | rd /s E:\$Recycle.bin
    echo J | rd /s F:\$Recycle.bin
    echo J | rd /s G:\$Recycle.bin

    echo Thanks Job done
    echo press any key to exit
    pause

    I am not using the English Win7 so you must change the Echo J in echo Y for the English version.

  11. Sorry update

    @echo off
    rd /s /q C:\$Recycle.bin
    rd /s /q D:\$Recycle.bin
    rd /s /q E:\$Recycle.bin
    rd /s /q F:\$Recycle.bin
    rd /s /q G:\$Recycle.bin

    echo Thanks Job done
    echo press any key to exit
    pause

    rem No pipe necessary the /q parameter (quiet)

    RD command

    Delete folder(s)
    Syntax
    RD pathname
    RD /S pathname
    RD /S /Q pathname

    Key
    /S : Delete all files and subfolders
    in addition to the folder itself.
    Use this to remove an entire folder tree.

    /Q : Quiet – do not display YN confirmation

  12. A safer way:
    cd \$Recycle.Bin

    make sure you are in the actual directory, then

    rmdir /s .

  13. @TheDutchman: Thank you! It worked.

    I have 3 OS’s installed and it was producing a lot of extra recycle bins. They had huge files in them and were impossible to delete with my weekly ccleaner routine.

    I found them in MyDefrag log under the “25 largest files” section. So they were definitely clogging up my disks.

  14. A Use this cmd

    rd /s %systemdrive%\$Recycle.bin

    del Recycle bin

  15. And then it says permission denied…. Why?

  16. For powershell you need to type following Remove-Item d:\`$recycle.bin -Force

Leave Your Comment


Message is the only required field.
Emails are not published.