The Weekly Geek

I'm the Geek so you don't have to be!

The Weekly Geek random header image

Running Automatic Disk Cleaning in Windows 2000 and XP

September 19th, 2003 · No Comments

Welcome to this weeks fun filled edition of The Weekly Geek!

Last week we went over how to schedule Disk Cleanup for Windows 9x computers. This week we are going to cover Windows 2000 and XP. Fasten your seatbelts, check your mirrors, start your engines and let’s get on to the road of knowledge. Oh, by the way you might want to grab a highlighter to mark through the steps you have done, this isn’t a short one.

When you schedule Disk Cleanup in Windows 2000 or XP the Microsoft console pops up but the program does not run.
To schedule Disk Clean Up in the Task Manager of Windows 2000 and XP and have it automatically run you need to run a couple lines of code. Don’t worry this is real easy.

  • First open the Command prompt by going to “Start | Run” and typing in “CMD”.
  • In Type in “cd\” this will take you to the C prompt (C:\), If you have XP type in “cd\windows\system32” and press the Enter key. If you have Windows 2000 type in “cd\winnt\system32” and then press the Enter key.
  • For either version you will type in “cleanmgr /sageset:1” the only space is between the r in cleanmgr and the forward slash (/) and the last digit is the number one. Press Enter after typing in the above information.
  • You will see the normal Disk Cleanup Settings screen. Here you will have the opportunity to select what you want cleaned up. Choose every check box execpt Office Setup Files and select the “OK” button on the settings menu and you will be back at the command prompt.
  • To be sure everything works out type in “cleanmgr /sagerun:1” and press Enter (while in the command windows). The computer should automatically start running the disk cleanup of all drives on your system.

What you have done is assign cleanmgr to clean all that you specified (the sageset command) each time it is run as rule 1. You can use the numbers 0 to 65535. The sagerun command tells the system to run your rule. After the test is successful open Notepad (Start | Programs (All Programs in XP) | Accessories | Notepad) to create a batch file.

  • In notepad type in “cleanmgr /sagerun:1”. Then save the file as a batch file.
  • To do this go to the “Menu” bar in Notepad and select “File | Save As” under the File Name type in “diskclean.bat” (you must add the .bat extension).
  • Next go to the “Save as type” line and from the drop down arrow choose “All Files”. This way you save the file as a batch file and not a text file.
  • You can save it anywhere you like, however for the sake of Best Practices I save it under the “System 32” folder (C:\windows\system32 for XP and c:\winnt\system32 for 2000).
  • To do this navigate through the system by clicking on the folders and then choose “Save”.
  • Close Notepad.

The final step is to create a Scheduled Task.

  • To do this, go to “Start | Settings | Control Panel” in Windows 2000 or “Start | Control Panel” in XP.
  • Select “Scheduled Tasks | Add Scheduled Task”.
  • On the first page of the Wizard select “Next”.
  • The next screen will take you to a choice of files to use, simply select Browse.
  • On the new pop up, browse to your batch file (diskclean.bat).
  • Click one time on “diskclean.bat” and then choose “Open” on the screen.
  • The next screen will let you name the routine, I always leave it the default name.
  • After selecting the “Next” button a new screen will appear, this screen allows you to schedule the frequency of the disk cleanup, as per my recommendation, I would suggest “Monthly.” You can choose the start time (if you constantly leave your PC on then I would suggest to run this at night otherwise I would recommend during supper) the day or time of month. As a rule of thumb I choose the “First Monday” of every month. When completed choose the “Next” button.
  • The next screen is very important. Here you select the user. Be sure that this person has administrative privileges and does not change their password frequently. To assure this, I use the permanent administrator I create for each machine. Under the “Enter the user name” be sure to enter the name of the PC followed by the forward slash and the under with administrative privileges name.

To find your user name (the one that appears when you first turn on your PC) navigate to the desktop screen or press the Windows key (Between the Ctrl and Alt keys) and M keys at the same time.

  • Next right-click on “My computer” choose “Properties” and then “Computer Name” tab for XP or “Network Identification” tab for 2000. The name is listed under “Full Computer Name”. If you don’t have a password, you can establish one.
  • Click “Start | Control Panel” in XP or “Start | Settings Control Panel” in 2000.
  • Double-click “User Accounts”.
  • Select the proper account.
  • Then select “Create a password”.
  • Fill in the blanks and click “Create Password” again.
  • Exit the windows.
  • Select the “Next” button to get to the properties selection. Once again I always choose the “Open advanced properties…” button to make a change and then select “Finish”.

You will have completed the Scheduled Task portion and be brought into the actual options menu. Select the “Setting” and change “stop the task if it runs for” from “72” hours to “12” and then select “OK”.

One final thing to do is to make sure everything will run. To do this go to the Scheduled Task list and right-click on your newly created task (diskclean) and then choose “Run”. You should see the “Disk Cleanup” box appear and run.
Depending on when you last ran the cleanup and how many drives you have this might take a while.

Whew! That was exhausting, go grab some hot chocolate or cold lemonade, sit back and relax in the full comfort of knowing you have just completed a job well done. Stay tuned for next weeks fun filled edition of The Weekly Geek when we will cover how to run a disk clean up for Windows 95 and NT, until then have a worm free week.

Tags: Hard Drives · Hardware · Optimizing · Speeding Up