Windows 10 Quick Tip: Emptying Recycle Bin in Command-Line

0

We all know the easy way to empty the garbage out of the recycle bin on Windows. Right-click on the Recycle Bin on the desktop and simply choose Empty.

image 19 600x330 - Windows 10 Quick Tip: Emptying Recycle Bin in Command-Line

Can it be done through a command-line so it can be part of something like a scheduled job or login script?

Sure thing apparently. Run the following in an elevated command prompt window.

rd /s %systemdrive%$recycle.bin
image 20 - Windows 10 Quick Tip: Emptying Recycle Bin in Command-Line

Note that if you have more than drives in your system, you need to clean them up individually.

Now, if you are familiar with PowerShell, Clear-RecycleBin is your friend.

Clear-RecycleBin

The cmdlet alone will clear all the local computer’s recycle bins. And you need to run it in an elevated PowerShell window.

image 21 600x216 - Windows 10 Quick Tip: Emptying Recycle Bin in Command-Line

With the -force switch, you can suppress the confirmation if you want to.

Clear-RecycleBin -Force

And if you only want to clean up the recycle bin on a certain drive, use the -DriveLetter switch

Clear-RecycleBin -DriveLetter D

Here is a bonus tip: how to open the recycle bin from a command line.

Start Shell:RecycleBin

LEAVE A REPLY

Please enter your comment!
Please enter your name here