How To Automatically Keep Windows 7 Clean Of Obsolete Files

Ads by Google

<firstimage=”http://www.makeuseof.com/wp-content/uploads/2011/07/FreeDiskSpace13.png”>clean windows 7 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.

clean windows 7 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.

obsolete files cleaner

Ads by Google

2. Create Basic Task

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

obsolete files cleaner

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.

obsolete files cleaner

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.

obsolete files problem

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

obsolete files problem

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

obsolete files problem

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.

autorun program

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.

change disk cleanup settings

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

command line

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.

customized disk cleanup

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

clean windows 7 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

Join live MakeUseOf Groups on Grouvi App Join live Groups on Grouvi
Windows Troubleshooting
Windows Troubleshooting
7 Members
Windows_10
Windows_10
6 Members
Windows Hacks & Customization
Windows Hacks & Customization
18 Members
Best Windows Software
Best Windows Software
10 Members
Ads by Google
Comments (17)
  • 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

    • 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.

  • Ben

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

  • Manuel Perez

    Very cool info!  Thanks!

  • Ankur

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

  • 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.

    • Tina

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

Load 10 more
Affiliate Disclamer

This review may contain affiliate links, which pays us a small compensation if you do decide to make a purchase based on our recommendation. Our judgement is in no way biased, and our recommendations are always based on the merits of the items.

For more details, please read our disclosure.
Affiliate Disclamer

This review may contain affiliate links, which pays us a small compensation if you do decide to make a purchase based on our recommendation. Our judgement is in no way biased, and our recommendations are always based on the merits of the items.

For more details, please read our disclosure.