Thinking through the Windows Task Scheduler

Windows is replete with secrets, you just need to know where to look to find them.

The Task Scheduler is one of those applications that empowers you to automate routine tasks.  You can essentially program your PC to perform certain actions when a specific trigger (or set of triggers) engage.  The nice thing is that all the programming is done with a point in click interface so you don’t need to know a lick of code.

For example:

  • You can create a task to automatically back up your hard drive but only when your laptop is plugged into the wall and is connected to your home network.
  • Or you could tell your computer to automatically start playing music at a certain time every morning.
  • Or maybe you want to set a task to restart your computer at the end of the day?

You’ll have to use a little bit of creativity because the tool is malleable but my goal today is to simply introduce you to the Task Scheduler, remove any trepidation you have about it and give you the fodder you’ll need to do something useful with it.

Let’s explore together.

The best way to become conversant with the Task Scheduler is to launch it and study it yourself.  So let’s do that:

Press the Windows Key and type:

scheduler

You should immediately see a convoluted screen with a a bunch of panes and text.

The first thing I want to point out is that the Task Scheduler isn’t complicated at all.

Yes, there’s a lot of information displayed up front but it actually makes a lot of sense if you take a moment to think about it.

The Windows 8.1 Task Scheduler

The anatomy of the Task Scheduler

The Task Scheduler is segmented into three panes:

The left most pane called the Console Tree is like a directory view of your tasks.

Just like you can organize files in folders so you can group related tasks in folders too.

Take a moment now to expand and click through some of the folders in the Control Tree.

Looking at Task Scheduler folders

The nice thing about the Task Scheduler is that it remembers your clicks. Directly under the menu bar you’ll left and right arrows.  Clicking these steps you through your actions so you can recall where you were in the tree.

If you have tons of tasks, moving through the console tree can feeling like navigating a labyrinth.  The left and right arrows will help you keep your sanity.

You can also simplify the chaos by hiding the Console Tree altogether.  One of the reasons the Task Scheduler looks so confusing is because the app immediately barfs up a deluge of data; some of which is unnecessary because it’s redundant because it’s redundant.

Couldn’t resist that inline redundant joke…

Back to business:  for example, once you browse to the correct folder, hide the console tree by clicking the Show/Hide Control Tree button which is located between the right arrow and the question mark icons under the menu bar.

Show or hide the console tree

You may also want to hide the right pane too, the Action pane, because the information there is a replica of everything under the Action menu.  Clicking the little icon to the right of the blue question mark leaves you with the Task Summary View and makes things a little easier to see.

The Task Summary view is the middle pane and has three horizontal panels:

  • Overview of Task Scheduler: An ultra-concise explanation of the Task Scheduler
  • Task Status: Displays a nice little dashboard showing your all the tasks that have started in the last hour, day, week or month.  For example, when I click the Task Status panel I see that I have 126 total tasks but only three are running, 1 is stopped and 1 failed.  One potentially annoying thing is that I haven’t found an easy way to sort by failed  or stopped task…  if you know share in the comments.
  • Active Tasks: shows enabled tasks.   These tasks aren’t necessarily running but they usually have triggers to run at some point in future.

Quick tip: Press F5 anytime to refresh the view.

Slimmed down Task Scheduler

Once you find the view you like, hit up the titular option in the menu bar and choose Customize…

Now you can save a custom view so it reliably displays the specific panes you want to see at loadtime.

Customizing the Task Scheduler view

So by default, the Task Scheduler shows three panes:

  1. Console Tree
  2. Task Scheduler Summary
  3. Actions

The Actions Pane is where… well – as they say on MTV cribs, where all the magic happens lol.

I actually prefer to hide it because I think it’s superfluous and complicates the view.  Let me show you what it does from the Action menu instead.

Task Scheduler Actions

Connect to Another Computer…

You can “snap-in” the tasks of another computer on your network and view them as if they were on your local machine.  Browse the network for the name or enter the hostname in the box.

You can also authenticate into that PC using different credentials than your currently logged in account.

Using Task Scheduler to connect to a remote computer

This presents a very powerful way to manage tasks on remote machines without using remote desktop.  All the tasks from the remote computer appear in your local Console Tree allowing you to view and stop all tasks or even create new tasks.  Just right click the top node in the Console Tree to see your options.

To resume viewing tasks on your local computer, go back to the Actions menu, select Connect to Another Computer… and this time choose Local computer (the computer this console is running on).

Create Basic Task…

The difference between creating a Basic Task and creating a Task is one word: detail.

The first one walks you through a four screen wizard that guides you through the process of creating a task.  It’s rudimentary.

Creating a basic task in Task Scheduler

The second more generic option, Creating Task… lets you peer behind the curtain into the details of task creation.  You get all your information up front which affords maximum creative control for creating tasks.

Initially all the tabs will look daunting – it did the first time I starting playing with tasks.

Creating a task with task scheduler

Import Task

You can export tasks, which basically means saving the data data as an .XML file.  When you select a task, the options under the Action menu gives you a new option to Export.   Conversely, the Import Task option is useful for pulling in backed up tasks.

Display All Running Tasks

Let’s continue our tour down the Action mention.

Display All Running Tasks lets you do a few things:

  • See all your currently running tasks
  • View the date and time they started
  • Look at how long they’ve been running
  • Check the exact file name and functions being called
  • Find out where the task resides on the file system

Show all running tasks

As always, F5 refreshes the view.

Disable all tasks history

By default, the Task Scheduler logs all task related events in the same way that the Windows Event Manager logs all system events.

The scheduler basically chronicles everything from when a task completes to when it was triggered.  As you can imagine, these logs can grow to voluminous sizes so sometimes it makes sense to disable all tasks history.

Windows Task Scheduler Details

AT Service Account Information

This refers to at.exe which was superseded by schtasks.exe (the Windows Task Scheduler).  I can’t imagine why you would need to click this option.

at.exe Task Scheduler

Getting things done

Alright, now that you’re conversant with the Task Scheduler layout, let’s start to do something with it.

Click the top node in the Console Tree to make sure the Actions menu displays the Create Basic Task… option.

Everything in the wizard is pretty self-evident.  For example, on the first screen you name your task and provide a brief description about what it does.  Then on the next screen we set a trigger.

The trigger’s sole purpose in life is to answer this question:

When will the task start?

You can make it automatically start daily, weekly or monthly.  You can also make it start only once, when you computer boots up, when you log in or when a particular event is logged.

You have a lot of creative freedom here.

Creating a basic task when a specific event is logged

There’s an interminable list of events from which you can include the associated EventID from the Event Viewer.

Let’s keep going.

Next, you should set the Action to Start a program since Send an e-mail and Display a message are deprecated.  Honestly, I don’t know why these two features are deprecated.  I perused the web for clues why Microsoft would discontinue work on these two features but I wasn’t able to find anything substantive.  If you have any ideas, let me know in the comments.

Task Scheduler Actions

You can then browse to the executable and insert any needed arguments.  On a side note, I’ve found that sometimes you can stuff all the arguments in the Program/script line and the Task Scheduler is smart enough to separate the arguments from the program itself.  The Start in option lets you specify the working directory where the task is being run from.

Clicking Next whisks you to the finish line and voila! Your task is created.


But what if you want more control over the tasks?

In my opinion, everyone should use the Basic Task Wizard once just so they can become familiar with the task creation process.  After that, you’ll find yourself using the more advanced option:  Create Task.

This is the big kahuna which lets you explore more options.

Let’s take a look here.

Concocting tasks without wizards

There’s no need for wizardry here – yes there are copious options and you might feel like you’re drowning under the deluge of information but I’m going to walk you through this.  We can do this.

The first thing you’ll notice are five benign tabs across the top of the window:

  • General
  • Triggers
  • Actions
  • Conditions
  • Settings

We’ll start in General and then work our way through the rest in a logical fashion.

My goal here is not to show you how to create specific tasks but rather to get you comfortable with the scheduler so you can boldly venture forth and create your own magic.

Maybe I’ll post some articles on some of the cool stuff I’m using it for but for now I’m just going to give you the stuff you need to get started.

Create Task in the Windows Task Scheduler

Alright so here’s what’s up:

  • Name
  • Location
  • Author
  • Description

Think of the task creation process as an author thinks of the novel writing process.  This quartet of introductory information is like the table of contents and publisher information you’ll find in most books.

It’s insipid but also imperative because it lets you identify the task (or book) in the future.


 

One note I should mention about the Location field.  Usually your tasks are stored in:

C:\Windows\System32\Tasks

This is considered your root folder (or simply backslash “\” as shown in my screenshot above).


 

Let’s examine our Security Options.

It says:

When running the task, use the following user account:

This means that the currently logged in user doesn’t have to be signed into the account that runs the task.  You can use any account or group that contains the users you want to kickstart the process.

Let’s investigate the other options:

  • Run only when user is logged on
  • Run whether user is logged on or not

This is an either or thing.  You can only run the task when the user you specified is actually logged into the computer that has the task or you can to run the task even if the user isn’t signed in.  This is great for automating routing tasks that run as different users.

After saving the task, Windows prompts you for the account credentials and then stores it for future use.

Task Scheduler password prompt

Let’s finish up with the final four options in the General tab:

  • Do not store password
  • Run with highest privileges
  • Hidden
  • Configure for:

Do not store password

This is good for sensitive situations.  The task scheduler authenticates with the provided password but promptly chucks it after gaining access.  Nothing is stored.

Run with the highest privileges

This is analogous to running the task as an Administrator; that is, running it with elevated privileges.  Try to avoid this if you can.  There’s no need to run a task in the elevated security context if you don’t have to. Don’t get me wrong: there’s nothing wrong with using this option but just make sure you check it because it was on purpose and not just because you think it’s something you should do.

Hidden

I’m not really sure what this does.  According to Microsoft, it’s supposed to hide the task from the Task Scheduler user interface; however, by default, Show Hidden Tasks is enabled and anyone could easily toggle this function.

So… what’s the point?

I’m not sure if this is Microsoft’s overture with security through obscurity or if there really is an intelligent purpose behind this option.  If I were you – I would skip it for now.  I can’t discern any real useful value you could gain for using this.

Configure for

Set this for the operating system you plan to run the task on.

Okay, that’s it for that – let’s move on to the next thing:  Triggers!

Kick off

Triggers are what kick the game off.

We can set one or more triggers that tell the computer exactly when to start the task, how often to run it and if there’s anything special about it.

For example, we can delay the task from starting, stop the task if it runs longer than a certain period and set the task to automatically expire at a specific date and time.

Powerful stuff.

Let’s talk about when we can set the task to start.  We have 10 options:

  • On a schedule
  • At log on
  • At startup
  • On idle
  • On an event
  • At task creation/modification
  • On connection to user session
  • On disconnection to user session
  • On workstation lock
  • On workstation unlock

On a schedule

This helps us answer the question:  When do you want the task to start and how often do you want it to run. Set that here.

Edit Trigger in Task Scheduler

At log on

If you click this, you can make the task run as soon as a specific user logs on to the machine or immediately after any user signs in.

At startup

Similar to At log on except the task leaps to action before any user ever has a chance to log in to the computer.

On idle

I love this one because you can make the task run only when the computer is in an idle state.  Meaning, the screensaver is running or there’s been zero percent CPU and disk usage for a time you specify in the Conditions tab.  I’ll show you that section in a bit.

On an event

Administrators love this one because it lets them trigger a task when a specific event publisher name or ID hits the log.  Can you feel the power man?  Are you feeling this? hahaha.

Alright let’s look at the others.

At task creation/modification

I like to think of this as a metatrigger.  Just as metadata is data about data so the task creation/modification trigger is a task for a task.

On connection or disconnect from user session

You can execute the task when the user either connects or disconnects a remote desktop session to the PC.  This also applies to fast user switching. So if I’m logging as user vhudson and click switch user to twoods the task triggers and starts running.

On workstation lock or unlock

User presses Windows Key + l or Ctrl + Alt + Del to lock the box and the task starts.  The same applies if you click the unlock option.

In the advanced section below you’ll see six additional options:

  • Delay task for:
  • Repeat task every
  • Stop task if it runs longer than
  • Activate
  • Expire
  • Enabled

Let’s look at the first one:

Delay task for up to (random delay)

This is an interesting setting.  Let’s say you set it to 30 seconds and your task is set to run On a schedule at noon daily.  This means, the task will run everyday at sometime between 12:00:00pm and 12:00:30pm.  So it effectively inserts a random start, or cushion, between the start time and the delay task for time.

Repeat task every

This sets the task to run for the value specified and to keep running for as long as the duration.  So if you set Repeat task every to 1 hour and the duration to 1 day, the task would run, finish and then wait a full hour before starting again. This loop would continue until 24 hours elapsed.

Stop task if it runs longer than

This is your kill switch.  It keeps the task from going bonkers.  I think if you ever select the previous option, repeat task every, then it’s judicious to set the stop task value too.  Windows will basically force quite the process if it tries to run longer than the value you put here.

Expire

When you need to set an expiry for the trigger itself, use the Expire option.  When the trigger crosses the expiration date it become impotent and won’t launch the task.

Enabled

Turns the task on or off.  Unchecking enable means the task can’t run until it’s enabled.

I know that sounds like common sense but I just want to be clear so you know exactly what everything does here.

Where the action happens

So now we have a good idea how to create a task, name it and configure triggers but what exactly is supposed to happen when the task runs?

That’s what the Actions tab is all about.

The chief action that most people use is to start a program.  Technically Microsoft allows you to send an email or display a message but since both of these values won’t make it to future versions of the operating system you may run into compatibility issues if you try to use them.

Again, don’t ask me why Microsoft yanked the plug on these because I have no idea.

Click the New button in the bottom left corner of the Action tab and then browse to the path of the executable (.exe file) you want to launch.

The Add arguments section has nothing to do with how contentious your application is.  lol.  It’s all about adding the command line switches that filter the command output.

For example:

  • You could start shutdown.exe with the -l (lowercase “L”) argument to log the user off at the end of the day.
  • Or you could run net.exe with the use option and the drive letter to make the computer automatically map that drive at Sign-on.
  • Or you could run cleanmgr.exe with the /sagerun argument.  Assuming the On a schedule trigger is set to monthly, every month the computer would automatically run a disk cleanup session.

Very useful.  The possibilities are limitless.

Incidentally, the Start in section is there for the working directory.  I think I mentioned that earlier but my I’m not sure.  My eyes are starting to glaze over now.

Launching a program

Use Conditions to tune Triggers

Conditions and triggers have a symbiotic relationship with one another. You use the former to fine tune the latter. Conditions are actually my favorite part of the task scheduler because they let you configure some really creative tasks.

Let me show you what I mean.

There are a sum of eight conditions that work in concert with the Triggers you configured earlier.  If one or more of these conditions are false, the task will not run.  The condition must be true in order for the task to start.

Here are the eight:

  • Start the task only if the computer is idle for
  • Wait for idle for
  • Stop if the computer ceases to be idle
  • Restart if the idle state resumes
  • Start the task only if the computer is on AC power
  • Stop if the computer switches to battery power
  • Wake the computer to run this task
  • Start only if the following network connection is available

Task Scheduler Conditions

There are basically two sections here:

The first four options deal with the idle state of the computer and the last four deal with power conditions.

Start the task only if the computer is idle for

Start the task, but only if the computer has been idle for the amount of time you put here.

Wait for idle for:

How long should the computer wait until until the computer hits the idle state?

Stop if the computer ceases to be idle

The computer stops being idle when you move the mouse or bang on the keyboard.  This option tells Windows to interrupt the task whenever it detects user initiated computer activity again.

Restart if the idle state resumes

If you leave this unchecked, then the computer won’t restart the task even if the PC becomes idle again.

Let’s looking at the powerful power stuff.

Here’s my favorite:

Start the task only if the computer is on AC power

If you think the task has the propensity to drain the battery, augment your Trigger with this energy saving Condition.

Stop if the computer switches to battery power

If you picked the first one you’ll probably pick this second one too.

Wake the computer to run this task

This is like the ultimate drill sergeant.  No sleeping cadets here.  If your computer is snoozing and it satisfies the time criteria you configured in your Triggers, it’ll wake up to start this task.

Start only if the following network connection is available

I almost forgot to mention this one!  You can say something like this:

“Hey Windows, only run this task when the computer is connected to my faster wired network at home” or “Only run this task when my laptop is connected to my mobile hotspot SSID”.  Very slick.


 

Okay!  Are we good there?   Feeling a little better about the task scheduler?

There’s still one last tab we need to poke around: the Settings tab.

Setting your task behavior

Let’s take a look here:

Task Scheduler Settings

Allow task to be run on demand

Translation: “Allow me to run this task whenever I want, not just when it’s scheduled”

Run task as soon as possible after a scheduled start is missed

You might be thinking:

How does this work?  I mean, how is it possible for the PC to miss a scheduled start?

Well if you shut the PC down before the task was scheduled to start or the computer froze for some reason it’s possible it could miss the scheduled task.  This little option attempts to galvanize the task to action again.

If the task fails, restart every

So the task tried to run but for some reason it failed.  It happens.  This option tells it to start again as often as you specify – up to the maximum number of times entered in the Attempt to restart up to box.

Stop the task if it runs longer than

You don’t want to permit an intractable task that continually vexes your end users.  This option sets the maximum allowable time that the task can run.  It’s also a great way to stay employed.

If the running task does not end when requested, force it to stop

It’s gameover.  Set this to completely and utterly kill that intractable task from running.    Think of it like the Ctrl+Alt+Del End task function.

If the task is not scheduled to run again, delete it after

Nice for cleanup.  It feels like unethical hackers would love this one to cleanup their tracks.

Incidentally, keep in mind that the history log stores all task creation and deletion actions so this would show up there.

If the task is already running, then the following rule applies:

Have you ever opened Google Chrome and discovered like a million chrome.exe processes running?  You don’t want this happening to your tasks.  To prevent the possibility of multiple instances of the same task running in memory you need to tell Windows how to deal with the attack of the clones.

If you pick Do not start a new Instance it won’t start a new instance and won’t mess with the current instance.  If you pick run a new instance in parallel you can run them side by side.

Queue a new instance puts the task in line to run when the current task stops.  Stop the existing instance kills the instance and starts the new one.


And that my friend is the Task Scheduler in all it’s exposed glory.

The Bottom Line

The power is there for you to exploit you just have to use a little creativity to make it work for you.

Sit down and think about what goal you’re trying to achieve and then map it to a task.  Test it a few times to make sure it works and then release it to the wild and admire your handy work.

Alright, that’s all I have.

New Years is in two days, wait – what’s today’s date?  Three days right?

Try bringing this up at the cocktail party when you’re swimming through confetti and ducking under vociferous party goers.  Sure, you’ll get a few weird stares and people will call you a loser for talking about the task scheduler on New Years day – but – so what?  Do it anyway and you’ll make me proud.

You’ll make me proud I tell ya haha.

Oh one more thing… if you haven’t had enough of the Task Scheduler check out Microsoft’s official documentation on how the Task Scheduler works.  Everything you need is there, except my personality so you might find it a bit… how do I say this: soporific? lol – okay I’m out thanks for reading!

About

Connect with Vonnie on Twitter

Posted in Windows, Windows 8, Windows 8.1 Tagged with: , ,
  • Pingback: Automatically sleep your PC when you're not using it - fixedByVonnie()

  • Tcat Houser

    If you want a rational for the hold over of the time based AT command, would be for the BASIC type scripting of command line batch files.

    IfExist
    :LabelName
    GoTo :LabelName
    ErrorLevel # (decending order)
    %1, %2 … varibles

    Really Old Geek, 512 bytes wedged in RAM (1) for commands more powerful than AT combined with BASIC run time type code that could read video memory for varibles.

    I once wrote 55KB .BAT That was AI for DOS based LAN running a Point Of Sale system.

    Beyond checking the order and conition of the 1.2 MB floppy backups, it was copying the data base hourly, running reports, time sheets…

    The b* was finding ANSI rhat was readable in mono and 256 color. Important display message; if chkdsk /f didn’t convert all lost clusters to chains after 3 attempts (If exist ERRORLEVEL # goto :actionlabel)

    Of course AT wouldn’t run backups or reports til after day close… and yes, I ran ifexist errorlevel = 0 to test for AT, Backup, chkdsk, etc when opening the batch. Things we’re much flakier then.

    My console based wizard really ran the show.

    (1) Seaware Systems, Fla, early ’80’s,V1&2 512 bytes RAM, #3 1024 Bytes (YES, you could Load High > 640k and < 1 MB RAM) Extended Batch Language).

    In essense, a mini BASIC languaage that could peek video RAM to derive varible states for command and control.

    So there is the trivia answer to AT in DOS and NT 3/4.

  • Pingback: How to display your Screen Saver immediately after locking the screen in Windows 8.1 - fixedByVonnie()