One of the things that I noticed with my desktop computer is that I’m constantly deleting large files, and after awhile it can consume quite a bit of space. I restart the computer a few times each week, and I decided that upon startup would also be a good time to have the Recycle Bin emptied.
After I started searching around I found that there wasn’t a special command designed to empty just the Recycle Bin. I did, however, stumble upon a way to execute the Disk Cleanup Wizard via the command line in a way that requires no user interaction. That means I could not only empty the Recycle Bin, but also temporary and other unneeded files.
Here’s what you have to do:
- From the command line run this line of code:
- A window should appear where you can configure what items you want cleaned/emptied when this profile (that we’ve designated as number 1) is run. Check the boxes for each of the options you want executed. Press OK when finished. Note that the Disk Cleanup will not run after you press OK.
- Now you need to create a scheduled task. In Vista the action you’ll want to assign will be:
And it should look something like this when entered in the New Action screen:
If you’re asked whether you want to run the program with the /sagerun:1 arguments you can press Yes.
- Now you can choose the rest of the settings yourself, such as when you want this to run. One of the options you can pick is to execute this when your computer starts.
- You’re done!
As you can imagine this tool can clean up a lot of different areas on your PC according to whatever schedule you setup. I’ve also started backing up my entire PC each night, and I have this script run before the process is initiated to ensure that unnecessary files aren’t being backed up. So it’s become a rather critical part of my daily routine.