How To Automatically Keep Windows 7 Clean Of Obsolete Files

FreeDiskSpace13   How To Automatically Keep Windows 7 Clean Of Obsolete FilesWindows has a way of collecting virtual dust, a circumstance that has not changed considerably in Windows 7. These obsolete files take up space and contribute to hard drive fragmentation. While neither of this is a big issue, it is an annoyance, one that you can easily take care of.

In this article I will show you a simple way to regularly and automatically clean your Windows 7 system. This won’t require you to install yet another cool tool and is thus low on system resources. At the same time you will also learn how to automatically run other tools for other tasks.

There are several tools that can remove temporary files and keep your computer free from clutter, for example CCleaner. However, these programs themselves take up hard drive space and consume system resources, thus adding to the problem rather than solving it. In fact, Windows comes with an accessory utility called Disk Cleanup, which does a pretty good job at freeing up space on your hard drive by removing temporary files, emptying the Recycle Bin, and deleting other obsolete files.

FreeDiskSpace01   How To Automatically Keep Windows 7 Clean Of Obsolete Files

You can run the tool manually by going through > Start > All Programs > Accessories > System Tools > Disk Cleanup. However, you can also schedule an automatic disk cleanup and that’s the procedure I am going to show you in this article.

1. Open Task Scheduler

Go to > Start and type > task scheduler in the search box, then hit > Enter.

FreeDiskSpace02   How To Automatically Keep Windows 7 Clean Of Obsolete Files

2. Create Basic Task

In the Task Scheduler windows go to > Action and select > Create Basic Task…

FreeDiskSpace03   How To Automatically Keep Windows 7 Clean Of Obsolete Files

3. Setup Task With Task Wizard

The previous step opened the Task Wizard. In the first window enter a name and description for your task, then click > Next.

FreeDiskSpace04   How To Automatically Keep Windows 7 Clean Of Obsolete Files

The Task Trigger determines when the task will be launched. In this case I want to the Disk Cleanup utility to run on a weekly basis. Click > Next to set the day and time.

FreeDiskSpace05   How To Automatically Keep Windows 7 Clean Of Obsolete Files

When you have decided on a schedule, click > Next to set an Action.

FreeDiskSpace06   How To Automatically Keep Windows 7 Clean Of Obsolete Files

Here we want to > Start a program. Select the respective option and click > Next.

FreeDiskSpace07   How To Automatically Keep Windows 7 Clean Of Obsolete Files

Enter the link to the respective utility in the > Program/script: field. The link for Disk Cleanup is > C:\Windows\System32\cleanmgr.exe. To run the tool automatically, without requiring your input, also add the command > cleanmgr.exe/sagerun:1 into the > Add arguments (options): field.

FreeDiskSpace08   How To Automatically Keep Windows 7 Clean Of Obsolete Files

Click > Next once more to see an overview where you can check your settings and then hit > Finish to save the task. In this configuration, the tool will run with default settings.

4. Change Disk Cleanup Settings

Naturally, it is desirable to change the default settings to suit your preferences. First of all, you basically need to save your preferred Disk Cleanup settings in a profile. Then you manipulate the command in the > Add arguments (optional): field above, to point to the instance of Disk Cleanup you launch with your scheduled task to the profile you created. This way you can set up multiple scheduled tasks, running different Disk Cleanup profiles. Now let’s see how that works.

Click > [WINDOWS] + [R] key combination to launch the Run Windows. Type in > Cmd and click > OK.

FreeDiskSpace09   How To Automatically Keep Windows 7 Clean Of Obsolete Files

In the DOS-like window that pops up, type in > cleanmgr /sageset:3 where ’3′ will be your new profile.

FreeDiskSpace10   How To Automatically Keep Windows 7 Clean Of Obsolete Files

The Disk Cleanup Settings window will launch. Select which files you wish to have cleaned, then click > OK to save your settings in a registry key.

FreeDiskSpace11   How To Automatically Keep Windows 7 Clean Of Obsolete Files

Now return to your scheduled task. Launch the Task Scheduler as described in step 1 above. Your task will be listed in the top middle column in the Task Scheduler window. Double-click the task, then switch to the > Actions tab and double-click the > Start a program action. In the > Edit Action window change the number for the > sagerun command to your profile number, for example to > cleanmgr.exe/sagerun:3

FreeDiskSpace12   How To Automatically Keep Windows 7 Clean Of Obsolete Files

That’s it! For more information about how to manipulate the Disk Cleanup utility, check out this Microsoft Support article.

For more tips and tricks on how to keep your Windows system lean and clean, check out these articles:

What tools have you been using to clean your hard drive?

Image credits: Kurhan

The comments were closed because the article is more than 180 days old.

If you have any questions related to what's mentioned in the article or need help with any computer issue, ask it on MakeUseOf Answers—We and our community will be more than happy to help.

17 Comments -

0 votes

Anonymous

Nice tutorial for advanced users.

0 votes

Tina

Well, I sure hope that it’s explained well enough so that also not so advanced users can follow. :)

0 votes

Joe Phillips

I think it is…  I use CCleaner, but knowing how to schedule a task is handy!

0 votes

Anonymous

Still using the manual approach. :)

0 votes

Heru Ammen

I use Disk Cleaner (http://diskcleaner.nl/) and Glary Utilities’ disk cleaner. I have used both for over two years and IMO they do the job quicker than win 7 disk cleanup utility.

0 votes

Merrie

… or you could download and install Wise Disc Cleaner Free, and with 1 click it just does the trick – easy as :)

0 votes

Tina

As I said, there are many tools that will do this and more.

0 votes

Bruce Epper

Even utilizing these tools the system will still perform sluggishly and will have a great deal of wasted space with all of the uninstall crap that is left on the system as a result of patching the OS and other MS software.  And removing some of the hotfix uninstallers can sometimes break later software patches.  Not a good scene.

For best results, I generally do a complete reinstall once or twice a year.  Nothing at all can beat that practice, it just sucks if you don’t cheat.  Since I’m using Win7, I keep VHDs of clean, fully patched 32-bit and 64-bit systems.  Before doing a reinstall, I sysprep the appropriate image and create a new installation disk that is already fully patched and has the largest software packages preinstalled (MS Office and Visual Studio) which are also already fully patched.  Easily shaves 8 hours or more off of my installation time.  After the reinstall, just put in the smaller software packages again & I am good to go for another 6 to 12 months.

0 votes

Tina

Re-installing the system of course is the cleanest way to start fresh, but it’s not very convenient.

0 votes

Ankur

Very informative article. I still prefer ccleaner but this option is good too .

0 votes

Manuel Perez

Very cool info!  Thanks!

0 votes

Ben

Can you write a tutorial for CCleaner too?  That would be nice:)

0 votes
0 votes

Ben

I meant write about scheduling Ccleaner to run at a certain time.  Like you did with Disk Cleanup.

0 votes

Tina

Sorry Ben, only now saw your second comment.

Essentially, you can use scheduled tasks to run any application. I don’t have CCleaner installed right now and I’m not sure whether it comes with an internal way to auto-run. Well, I will check it out and see whether this warrants a new article. Thanks for the suggestion!

0 votes

Roozbeh Razavi

I’ve a question Tina. Why did you put sagerun:1 in the 3rd step and then change it to sagerun:3 in the last step? You could create sagerun:1 via cmd! Am I right or not? Can you please explain it for me? Thanks

0 votes

Tina

Roozbeh,

the number indicates the disk cleanup profile. In the first example I ran profile number 1. In step 4 I explained how to create a new profile 3, using the sageset command. The only new information in that step is how to create a different profile.

You can manually run sagerun:1 (or any other profile) via the cmd line of course. The whole point of this article, however, was to explain how to automate disk cleanup using scheduled tasks.