You can use it to clear the Recycle Bin at a specified time or regular intervals with Task Scheduler using a PowerShell command. Alternately, you can also use Storage Settings (a.k.a. Storage Sense) to clear the files from Recycle Bin that are older than a certain number of days.
This article discusses the two methods to clear the Recycle Bin automatically at predefined intervals.
How to Automatically Empty the Recycle Bin in Windows 10
Method 1: Using Storage Sense
The Windows 10 Storage Settings has a feature which lets you delete files in the Recycle Bin that are older than “x” days.
- Open Settings, System, Storage
- Enable the radio-button near the option “Storage can automatically free up space…” under Storage.
- Click Configure Storage Settings or run now. This opens the configuration page where you can choose the items you want to automatically delete using Storage Sense.
- Under Delete files in my Recycle Bin if they have been there for over, choose one of the options listed. In Windows 10 v1903, this option provides you 5 choices, namely: “Never”, “1 day”, “14 days”, “30 days”, “60 days”. Choose one of the options as required.
That’s it. The Storage Sense will automatically delete older files in your Recycle Bin.
Method 2: Using a PowerShell command with Task Scheduler
As you know, PowerShell has a built-in cmdlet to clear the Recycle Bin automatically using the following command, which you can also automate with Task Scheduler.
powershell.exe -command Clear-RecycleBin -Force
PowerShell.exe from Task Scheduler would display the PowerShell window every time the task runs. To avoid that, you can run the above command in hidden mode by launching it with a VBScript.
- Create a VBScript from the following contents. To do so, copy the following contents to Notepad and save the file with .vbs extension — e.g.
Set WshShell = WScript.CreateObject("WScript.Shell") WshShell.Run "powershell.exe" & " -command Clear-RecycleBin -Force", 0, 0 Set WshShell = Nothing
Optionally, you may move the VBScript file to your Windows directory if required. The next step is to create a scheduled task to run the above script to empty the Recycle Bin at required intervals.
- Open Task Scheduler, and click Create a Task… in the Actions pane.
- Type the name of the task and assign a description.
- Click the Triggers tab, and click New.
- In the “Begin the task:” drop-down box, select an option from the list. In this example, I chose to run the task At log on, by any user in the system.
- Click OK. Select the Actions tab, and click New
- In the Program/Script: text box, type the following:
- In the Add arguments (optional): text box, type:
- Click OK, OK.
That’s all. The Recycle Bin should be cleared automatically at every log on, or at the specific time intervals if you’ve set any.
Note: Earlier versions of PowerShell don’t include the Clear-RecycleBin cmdlet. In that case, you may either upgrade PowerShell or use the excellent NirCmd command-line automation tool to clear the Recycle Bin silently.
One small request: If you liked this post, please share this?One "tiny" share from you would seriously help a lot with the growth of this blog. Some great suggestions:
- Pin it!
- Share it to your favorite blog + Facebook, Reddit
- Tweet it!