How to Create a Scheduled Task

Scheduled tasks run periodically in the background. They're useful for tasks that you want your computer to do routinely, without you having to manually intervene.

Shows the main Task Scheduler window.

Click "Create Basic Task...".

Shows how to create a basic task.

Enter a name for the task, and click "Next".

Shows how to create a basic task

Specify the frequency, and again click "Next".

Shows how to create a basic task

Enter a time and day of the week (or the relevant parameters for the frequency you chose in the previous step).

Shows how to create a basic task

In the next window, specify the type of action that you want to perform.

Shows how to create a basic task

In the next window, you need to specify the task that you want to run. You do this by using the "Browse..." button to select the appropriate executable. When you click this button, it automatically opens the C:\Windows\System32 folder, where the executables for tools provided with Windows reside. In this example, we're going to select the “cleanmgr.exe” file, which is the executable for the disk cleanup tool. We'll explain later how you would find the executable file you're looking for.

In this window, you can also add optional arguments to the executable. Again, we'll explain later how you would do this, and what the relevant arguments for the disk cleanup tool would be.

Shows how to create a basic task

Finally, the last window shows the details of the task we've just set up, and asks us to confirm the creation of the task.

To view all of your scheduled tasks, and to edit or delete individual tasks, click on "Task Scheduler Library" on the left-hand side of the Task Scheduler window. You can then scroll through your scheduled tasks, select the one that you want, view its settings using the various tabs in the bottom part of the window, edit these settings using the "Properties" button in the “"Actions" list on the right-hand side of the window, or delete it by using the "Delete" button which is also in the "Actions" list.

Shows the completed task in the Task Scheduler window.

How to Locate an Executable

When you access an application via a menu or a shortcut, you don't know the actual location of the executable file associated with it. The easiest way to find this is to right click on the menu item or shortcut, and select "Properties" from the pop-up menu.

Shows how to access the properties for an application.

In this case, the properties window tells me that the executable for Disk Cleanup is located at: %SystemRoot%\system32\cleanmgr.exe.

Shows how to find the pathname for an application.

This looks a little strange, but the "%SystemRoot%" is just a reference to a variable which Windows uses to specify the location of the Windows system files. In most cases, this is C:\Windows, so the full path would be C:\Windows\System32\cleanmgr.exe.

If you want to check what this and other variables are set to, you can do so in a Command Prompt window (accessible via Start menu -> All Programs -> Accessories -> Command Prompt). If you just type "set", it will display all environment variables with their current values.

Shows how to find the values of environment variables.

How to Find Command Line Arguments/Parameters

When run from the command line rather than through the normal graphical interface (which is what happens with scheduled tasks), many executables have additional arguments (also  referred to as parameters, options or switches) which can be specified to control how they operate. In order to make sure that your scheduled tasks will run correctly and do what you intend, you need to understand these parameters, but this can be tricky to find out.

Some commands support a "-?" argument which lists the valid parameters. An example is the defrag executable. If I start a Command Prompt from the Start menu -> All Programs -> Accessories -> Command Prompt, and then type "defrag -?", I get a list of the valid arguments that I can add.

Shows how to find the available parameters for the disk defragmenter.

What this tells me is that I need to specify the drive, and can add an option like "-f”" to force defragmentation even if space is low. To do this, I could add the parameters "C: -f" in the "Add arguments (optional)" field when specifying the program to run. If I want to add this parameter later, then I need to open the task properties (explained above), go to the "Actions" tab, and edit the action to add this.

Disk Cleanup is a little more complicated, in that the executable isn't as friendly, so it doesn't list the options for you. Also, you need to configure the options that you want to use for the scheduled task in advance.

You need to open a Command Prompt (as above), and type "cleanmgr /sageset: 1" (or any other number). A window opens in which you can specify the types of files you want Disk Cleanup to remove.

Shows how to configure settings for disk cleanup.

Check the boxes for the types of files you want to cleanup, and click “OK”. Now, you've configured a set of options for Disk Cleanup, and the next step is to tell the scheduled task to use these options. To do this, you need to add the parameter "/sagerun: 1" (or whichever other number you chose when configuring the settings) to the command. The method for doing this is the same as for the defragmentation example given above.

The arguments for a particular command should be specified in the documentation associated with it. For Microsoft applications (such as cleanmgr), a good reference for information like this is the Microsoft Help and Support website.

<-- Previous Page

Use System Restore

Next Page -->

Frequently Asked Questions