In this edition of Geek School, we’re going to teach you about the extremely powerful Task Scheduler utility that Windows uses behind the scenes to do all sorts of things.
You might be thinking that the Task Scheduler is just a way to schedule an application to run at a certain time, but it is so much more than that, and has become an integral part of Windows.
In the old days, Windows had a ton of Services running in the background at all times just to do things like trigger system cleanup events or maintenance that had to run at a particular time. Modern versions of Windows abandoned this practice as much as possible, and instead just added events to the Task Scheduler so that they would do the same thing, but without requiring a running process and wasting memory all of the time.
This doesn’t mean that Windows has no services running, of course, because many things need to stay running all the time in the background, both because they require constant activity and to communicate with other processes. But the migration of system tasks to the Task Scheduler has been a great thing for PC users.
Understanding the Task Scheduler Interface
When you first open the Task Scheduler application, you’ll see three panes of information: the left-hand pane with a list of folders in a tree format that is used to organize the list of scheduled tasks, the middle pane that displays the tasks themselves, and the Actions pane on the right that gives you quick access to common menu items.
Don’t be intimidated by all of the things in the interface – it is really quite simple and there aren’t as many options at the cluttered interface make it seem that there are.
The right-hand pane can actually be disabled using the right-most icon on the toolbar, as all of the actions are also available in the Action menu. If you have a task selected from the list, the menu will change to a task specific set of items like Run or End, but when you first open Task Scheduler or don’t have a task selected, you’ll see the options to create tasks, display running tasks, and all the rest.
We’ll explain how to create tasks in a minute, but first we should go through some of the options in the list and explain what they do.
- Create Basic Task gives you a wizard interface for creating scheduled tasks.
- Create Task uses the full detail view where you can manually create a task with any option you want.
- Import Task lets you import tasks that you have previously exported. Very useful for copying a configuration to a secondary PC, or adding a task back after reinstalling.
- Display All Running Tasks shows a list of all the tasks that are currently running as well as what folder you can find that task in.
- Enable / Disable All Tasks History turns on detailed logging for everything that Task Scheduler does.
- New Folder… creates a new folder in the left-hand pane, mostly useful for organizing a bunch of scheduled tasks, should you ever need to do that.
- Delete Folder deletes the folder that you made and realize you didn’t need in the first place.
- Refresh and Help should be self-explanatory.
The “Display All Running Tasks” option pops up a really simple list that shows which tasks are currently running, although it never seems to populate the Started or Run Duration columns. In any case, it’s handy to see if things are running.
The Enable / Disable All Tasks History option is really useful because it enables the History tab and tracks almost everything that happens. If you are troubleshooting a problem that involves a Scheduled Task, you should enable this option to get more data to work with – just make sure to disable it again afterwards, because that is a lot of unnecessary logging that might slightly degrade performance if you don’t need it.
We’ll go into great detail shortly about the details of the rest of the task detail tabs, but it is worth looking through many of the folders to see the types of things that are being run with a scheduled task by Windows or third-party software.
For instance, if you head down into the Microsoft -> Windows -> Defrag folder, you’ll see the ScheduledDefrag task in the list. The actions tab shows you what is actually being run behind the scenes, and you can check out what the rest of the options are set to.
Note: we wouldn’t recommend messing around with the options for built-in Microsoft services. Consider it informational only.
Another fun example is the Microsoft -> Windows -> ApplicationData folder, which has the CleanupTemporaryState task. Looking at the Actions tab tells us the actual command line, which uses the rundll32.exe component to run the Windows.Storage.ApplicationData.dll file, and calls the CleanupTemporaryState function within that DLL.
What does this mean? You can feel free to look it all up for yourself, but essentially all .NET applications provide the ability to use the ApplicationData functions to create temporary files or data that are only for the current session. So Windows calls the CleanupTemporaryState function every so often to clear out those temporary files, which are also located in the regular Windows Temp folders.
Since you are already wondering, you don’t need to manually trigger this task to keep your PC clean – if you want to clear out those temporary files, just use Disk Cleanup or something like CCleaner. But it’s fun to learn a little more about how Windows works under the hood.
Speaking of Disk Cleanup, did you know that Windows will automatically run it in silent mode whenever you are really low on disk space?
The command line for this scheduled task shows how it is done – by passing the /autoclean and /D %systemdrive% arguments to cleanmgr.exe, Windows tells Disk Cleanup to automatically run and to clean the drive that Windows is installed on.
You’ll notice with some of these built-in tasks that the Trigger might not be set. That could be for a variety of reasons, including that Windows might trigger the scheduled task a different way.
Creating Basic Tasks with the Wizard
Now that we’ve gone through some of the options in the interface, the only thing remaining is to understand how to create tasks.
The Basic Tasks wizard helps you quickly create a task without needing to understand everything about the interface. It’ll prompt you for a Trigger, which is what Windows uses to decide when to run the task. The trigger could be a time or date, whether daily, weekly, monthly, or just every other Tuesday at 1PM. The options are very powerful once you select one and head to the next screen.
You can also choose to launch a task when the computer starts, when you log on, or even when a specific event shows up in the Event Viewer, which we’ll be covering in the next lesson.
Once you get through the Trigger settings, you’ll be prompted for the Action that you want to perform, which is just a way of saying that you will use this screen to start a program. You can still select to send an email or display a message, but chances are good that the feature will be removed in a future version, since they both show up as deprecated now.
On the next screen you’ll be prompted for a program or script, and you can add arguments to that script as well. The last option for “Start in” is really useful if your application or script is looking for a file in the current folder, so you can set the current folder to where the file is.
That’s all there really is to it for creating a task using the wizard, but that is just the rookie way to do things.