- Worldstart's Tech Tips And Computer Help - http://www.worldstart.com -

Clean Up Your PC Automatically

Note: This will only work on Professional editions of Windows XP, Vista, and Windows 7.

Unwanted files and folders have been plaguing PC users since the first computers were made. And, it goes beyond operating systems.

Whether you’re using Windows, Linux or a have a Mac, excess files will always clutter your computer and consume precious hard drive space.

Every time you install a program, surf the web or use an application, new files and folders are created on your computer. Some are created by you and are useful, but many others are temporary files, copies of files or files that are obsolete.

Sure, you could delete them manually, but they would just end up in the Recycle Bin. Then, you’d have to delete them all over again, only to start over the next day.

It’s a problem that, so far, has no solution. However, there is a way to lessen the impact this problem has on your time.

Just let Windows handle the cleanup process automatically.

Despite the huge number of programs promising to rid your computer of unwanted files, you don’t need to use any third party cleanup software.
Windows has its own cleanup utility that will do a better job at cleaning your computer of excess files and folders. Moreover, it will not bother you with adware or toolbars.

Using the Disk Cleanup Tool integrated in Windows and the Local Group Policy Editor, you can create an automated command to empty the Recycle Bin and delete temporary files and other unwanted files from your computer at each shutdown.

I’ll show you how, in the next steps.

First, we need to access the Disk Cleanup Tool.


Go to the Start Menu and click on the Run command, situated above the Turn off Computer button (or the search field in Vista and 7).

Then type the command cleanmgr /sageset:1 in the Open box and click the OK button.

Note: To access the Disk Cleanup Tool in Windows Vista and Windows 7 you must log in with an administrator account.


In the Disk Cleanup Settings window, check all the items on the list and click OK.

Now, we need to open the Local Group Policy Editor.

Go to the Start Menu and click on the Run command, situated above the Turn off Computer button. Then type the command gpedit.msc in the Open box (or the search field in Vista and 7) and click the OK button.

Note: To access the Local Group Policy Editor in Windows Vista and Windows 7 you must log in with an administrator account.

The Local Group Policy Editor will now open.


On the left side of the window, under User Configuration, double-click the Windows Settings folder.

Then, under Windows Settings, click on Scripts (Logon/Logoff).
On the right side of the window, double-click the Logoff option.

In the Logoff Properties window, click the Show Files… button.

This will open the Logoff folder. We need to create a command file in this folder that will run automatically at every system shutdown.

Before we create the file, we need to go into the advanced folder options and make Windows show file extensions.


Still in the Logoff folder, click on Tools (located in the top left). Then click on Folder Options…, from the menu.

In the Folder Options window, click on the View tab. Uncheck the Hide extensions for known file types box and click OK.

Back in the Logoff folder, right-click on an empty spot and from the menu choose New and then click on Text Document.

Name this new file Cleanup.cmd, press the Enter key and click Yes.

Note: Make sure the file has the .cmd extension (cog icon) and not the .txt extension (notepad icon).

Now, right-click on the Cleanup.cmd file and choose Edit from the menu. This will open the file in Notepad.

Next, type cleanmgr /sagerun:1 and press Ctrl + S from the keyboard to save the file.

Close the Cleanup.cmd file and the Logoff folder and go back to the Logoff Properties window (follow the steps above if it’s closed).


Next, click the Add… button, then click the Browse… button, in the Add a Script window.

Now, click on the Cleanup.cmd file, click Open and then OK.

In the Logoff Properties window, click OK and exit the Local Group Policy Editor.

That’s it! You’re done.

Now each time you shutdown the computer, the Disk Cleanup Tool will start to remove any temporary files and empty the Recycle Bin.

Note: If you use Windows Vista or Windows 7, the User Account Control security feature could block the script from running. As such, the Cleanup script might ask you to enter an administrator password to continue or it might not work at all. One solution would be to change the User Account Control options to a lower setting and allow the script to run.

~Cosmin Ursachi