This is pretty much the easiest and fastest way to do it

Feb 22, 2019 13:23 GMT  ·  By

As all Windows users know, emptying the Recycle Bin only comes down to a right-click on its icon, and it’s something that many people do, not only to keep things organized on their devices, but also to avoid leaving any traces behind.

Deleting the contents of File Explorer, however, shouldn’t be a manual task, and fortunately, Windows 10 comes with options that let you automate the whole process so you can forget about removing files.

For example, one way to make sure that no data remains in File Explorer is to always delete files with Shift + Delete in Windows. This shortcut no longer sends files to Recycle Bin, but erases them forever, making them impossible to recover.

But at the same time, if you still want to use the Recycle Bin, you can just set a task that takes care of the whole thing for you. And today, I’ll show you how to automatically remove all data in Recycle Bin when shutting down your computer.

What’s important to know is that you’re going to need Windows 10 Pro for this because the method involves working with the Local Group Policy Editor on the device. You also need to be logged in with an administrator account on the system.

First and foremost, we’ll have to create a script whose mission will be to empty the Recycle Bin whenever it runs. The easiest way to do it (and the simplest command) is the following:


PowerShell.exe -NoProfile -Command Clear-RecycleBin -Confirm:$false
Create a new document, paste the following command in it and then save it on the desktop with whatever name you want – I suggest you call it “Empty Recycle Bin script” just to always be able to figure out your purpose, which comes in handy especially if you have multiple scripts in the same location.
The script you can use for automatic cleaning

At this point, because you used a text document to create the file, it should use the .txt extension, so rename it to .bat. This means you should end up with a file using this name on your desktop:


Empty Recycle Bin script.bat
You can easily test it by placing some files in the Recycle Bin and then launching the script. If the files in Recycle Bin are removed, everything’s working correctly.

Now, you need to configure this script to run at shutdown. There are several ways to do this, but because you’re on Windows 10 Pro, you can use the Local Group Policy Editor to set up a new policy for your device.

Click the Start menu or press Windows key + R and type the following command:


gpedit.msc
Browse to this location in the Local Group Policy Editor:
Computer Configuration > Windows Settings > Scripts > Shutdown
In the Shutdown screen, click Add > Browse and provide the location of the script you created earlier. If you followed the steps precisely, the script should be located on the desktop. There’s no need to provide additional script parameters because they’re already defined in the command that you added to the script.

At this point, everything is ready. The next time you reboot the computer, Windows should automatically run the script, which in its turn automatically empties the Recycle Bin.

Setting the script to run on shutdown

I suggest you to first run a test and see if everything is working correctly by placing a number of files you no longer needton Recycle Bin and then shut down the device. If they’re no longer there when logging in to the desktop, you’re good to go.

Keep in mind that setting up such a script to run at shutdown you might lose important data that you accidentally send to Recycle Bin. In most of the case, the data is difficult or impossible to recover.

Photo Gallery (3 Images)

Recycle Bin in Windows 10
The script you can use for automatic cleaningSetting the script to run on shutdown
Open gallery