Automating Tasks in Windows

I’m going to show you two easy ways to automate tasks in Windows, but first let’s establish some specifics about what we want to do.

The easiest way to clean temporary folders is to use Windows built in Disk Cleanup Tool which can be started either from All Programs > Accessories > System Tools on the Start Menu or from the command line using cleanmgr.  By default this program has a GUI Interface meaning that it displays prompts that require user input in order to run, so before we can automate it we need to create saved settings for it to use so that we don’t have to do it manually. This is useful if your schedule your automated task to run when you are not at your computer. Microsoft has already considered this scenario and built the Disk Cleanup Tool with this option.

Saving Disk Cleanup Tool Settings for future use

  1. From the Start Menu choose Run…
  2. Enter the following cleanmgr /sageset:11
  3. Set all of the settings that you would like to run automatically.

Now whenever you want to run Disk Cleanup Tools with these settings you can use the command line cleanmgr /sagerun:11.

Option 1: Automating Windows XP using Scheduled Tasks
Windows Task Scheduling is a built in feature that allows a user to run specific tasks including programs, scripts, and documents at specific times or intervals. So let’s create an automated task.

  1. Click Start > All Programs > Accessories > System Tools > Scheduled Tasks.
  2. Double – click Add Scheduled Task and then click Next.
  3. Click the Browse… button.
  4. Navigate to the C:\Windows directory.
  5. Select cleanmgr.exe and click Open.
  6. Follow the prompts to create your new task.
  7. Right-click your newly created task and choose Properties…
  8. Change the contents of the run box to our command line cleanmgr /sagerun:11.
  9. Click Apply and OK.
  10. Your new task will run as scheduled.

For more information on creating Scheduled Tasks check out this Microsoft Knowledgebase article;en-us;308569&sd=tech

For information about editing created tasks check out this article;en-us;308671&sd=tech

Option 2 : Automating Tasks at Windows Startup
The second way to automate a task is to create a shortcut in the StartUp folder which executes everytime windows loads. The Startup folder is located on the Start Menu under All Programs.

  1. Right-click a blank area on your desktop and choose New… > Shortcut.
  2. In the Run box use our command line cleanmgr /sagerun:11.
  3. Give your shortcut a name and click Apply and OK.
  4. Drag your new shortcut over the Start Button and continue to hold the mouse button down.
  5. After a couple seconds the Start Menu will expand. Continue moving through the folders until you reach All Programs > StartUp.
  6. Drop the shortcut anywhere that a black line appears inside of the StartUp folder.

Alternately you could navigate to the StartUp folder in My Computer or Explorer and create the shortcut there directly by right-clicking and choosing New… > Shortcut. The system wide StartUp folder is located in the Windows Directory usually C:\Windows\StartUp or C:\WINNT\StartUp. The user specific location is under C:\Documents and Settings\username in XP or C:\Users\username in Vista.

These ways can be used to automate virtually any task on your PC as long as you know the programs location or a specific command line. Hope this helps.


Like the read? Share it!


  • Excellent, 😀

  • I found AutoIT to be more userful for automating Windows tasks. As most people searching for automation usually want to do more than just the basics. AutoIT does it all. That is my 2 cents worth….lol

  • AutoIt is ok, but nothing special if you ask me. It does simplify scripting a bit, but it adds another dependency which makes it a bad solution for network environments.

Leave a Reply


Wanna say hello?
Drop us a line!

You'll find us here

1 Microsoft Way,
WA 98052, United States