When you manage desktop and laptop systems, you’ll often
want to perform routine maintenance tasks on a periodic or recurring
basis. To do this, you can use the Task Scheduler service to schedule
one-time or recurring tasks to run automatically. You automate tasks by
running command-shell scripts, Windows Script Host (WSH) scripts, or
applications that execute the necessary commands for you. Unlike
earlier releases of Windows, Windows 8 includes an extensive library of
preconfigured tasks. These tasks handle everything from uninstalling a
Bluetooth device to defragmenting disks to performing Windows Defender
scans.
Understanding Task Scheduling
Windows 8 provides several tools for scheduling tasks, including the Task Scheduler, the Schtasks
command-line tool, and several Windows PowerShell cmdlets. You can use
any of these tools for scheduling tasks on local and remote systems.
The Task Scheduler includes several wizards for scheduling tasks that
provide point-and-click interfaces for task assignment. Schtasks is the
command-line counterpart. Windows PowerShell cmdlets available include
New-ScheduledTask, New-ScheduledTask Action, Set-ScheduledTask,
Start-ScheduledTask, and StopScheduledTask.
All of these scheduling tools use the Task Scheduler service to
monitor the system clock and run tasks at specified times. The Task
Scheduler service logs on as the LocalSystem account by default. This
account usually doesn’t have adequate permissions to perform
administrative tasks. To overcome this problem, each task can be set to
run as a specific user, and you set the user name and password to use
when you create the task. Be sure to use an account that has adequate
user privileges and access rights to run the tasks that you want to
schedule.
Windows 8 has two general types of scheduled tasks:
-
Standard tasks Used to automate routine tasks and perform housekeeping. These tasks are visible to users and can be modified if necessary. -
Hidden tasks Used
to automate special system tasks. These tasks are hidden from users by
default and should not be modified in most cases. Some hidden tasks are
created and managed through a related program, such as Windows Defender.
In Windows 8, the creation and management of tasks is much more
sophisticated than ever before. Every task can be configured to do the
following:
-
Run only when a user is logged on, or run regardless of whether a user is logged on -
Run with standard user privileges, or run with the highest privileges required (including administrator privileges)
Because tasks created on Windows 8 are not compatible with earlier
releases of Windows, you cannot copy a Windows 8 task to a computer
running an earlier release of Windows and expect the task to run.
However, when creating the task, you can specify that it should be
created so that it is compatible with earlier releases of Windows. This
allows you to use the task on computers running earlier releases of
Windows.
Tasks can have many properties associated with them, including the following:
-
Triggers Triggers
specify the circumstances under which a task begins and ends. You can
begin a task based on a schedule as well as on user logon, computer
startup, or processor idling. You can also begin a task
based on events, a user connecting or disconnecting from a Terminal
Server session, or a user locking or unlocking a workstation. Tasks
with event-based triggers can be the most powerful because they allow
you to provide automated ways to handle errors and warnings. -
Actions Actions
define the action a task performs when it is triggered. This allows a
task to start programs, send email messages, or display messages. -
Conditions
Conditions help qualify the conditions under which a task is started or
stopped once it has been triggered. You can use conditions to wake the
computer to run a task and to start the computer only if a specific
network connection is available. You can use conditions to start, stop,
and restart a task based on the processor idle time. For example, you
might want to start a task only if the computer has been idle for at
least 10 minutes, stop the task if the computer is no longer idle, and
then restart the task again if the computer becomes idle once more. You
can also use conditions to specify that a task should start only if the
computer is on alternating current (AC) power and stop if the computer
switches to battery power.
Viewing and Managing Tasks on Local and Remote Systems
The current tasks configured on a system are accessible through the Task
Scheduler node in Computer Management. Tasks are organized and grouped
together using a familiar folder structure, where base folders are
named according to the operating system features, tools, and
configuration areas to which they relate. Within a base folder, you’ll
find one or more related tasks.
You can view and manage the scheduled tasks configured on a computer by completing the following steps:
-
Open Computer Management. You are connected to the local computer by
default. If you want to view tasks on a remote computer, press and hold
or right-click the Computer Management entry in the console tree (left
pane), and then tap or click Connect To Another Computer. In the Select
Computer dialog box, enter the name of the computer that you want to
access, and then tap or click OK. -
Expand the Task Scheduler node, and then expand the Task Scheduler Library node and related subnodes as necessary. -
When you select a task folder in the console tree, the first task in
the folder is selected by default. If the folder has multiple tasks and
you want to work with a different task, select that task instead. -
When you’ve selected the task you want to work with, you can view its properties by using the tabs shown in Figure 1. If you want to manage the task, press and hold or right-click the task in the main pane and then do the following:
-
Tap or click Delete to delete a task. -
Tap or click Disable to disable a task. -
Tap or click Properties to edit the task’s properties. Make the
appropriate changes in the Properties dialog box, and then tap or click
OK. -
Tap or click Export to export a task to a file that can be imported
on another computer. After you export the task, use Computer Management
to connect to the other computer, press and hold or right-click the Task
Scheduler Library node, and then tap or click Import Task. You can then
use the Open dialog box to locate and open the task on the other
computer. -
Tap or click Run to run the task. -
If the task is running, tap or click End to stop the task.
Note
Although you can modify and delete user-created tasks, most tasks
created by the operating system cannot be configured or deleted. If
operating system tasks are not shown, you can display these tasks by
tapping or clicking View and then selecting Show Hidden Tasks. Note
also that when exporting tasks, the task’s Configure For setting
determines the operating systems with which the task can be used.
Although earlier releases of Windows had different scheduled task
architectures, Windows 8 and Windows Server 2012 share the same
architecture as Windows 7 and Windows Server 2008 R2.
You can view the scheduled tasks currently running on a computer by completing the following steps:
-
Open Computer Management. You are connected to the local computer by
default. If you want to view tasks on a remote computer, press and hold
or right-click the Computer Management entry in the console tree (left
pane), and then tap or click Connect To Another Computer. In the Select
Computer dialog box, enter the name of the computer that you want to
access, and then tap or click OK. -
Select the Task Scheduler node to read in its attributes. Press and
hold or right-click the Task Scheduler node, and then select Display
All Running Tasks.
You can create a scheduled task by completing the following steps:
-
Open Computer Management. You are connected to the local computer by
default. If you want to create tasks on a remote computer, press and
hold or right-click the Computer Management entry in the console tree
(left pane), and then tap or click Connect To Another Computer. In the
Select Computer dialog box, enter the name of the computer that you
want to access, and then tap or click OK. -
Select and then press and hold or right-click the Task Scheduler node, and then tap or click Create Task. This starts the Create Task Wizard. -
On the General tab, type the name of the task, and then set security options for running the task.
-
If the task should run under a user account other than that of the
current user, tap or click Change User Or Group. Use the Select User Or
Group dialog box to select the user or group under which the task
should run, and then provide the appropriate credentials when prompted
later. -
Set other run options as necessary by using the options provided. By
default, tasks run only when a user is logged on. If you want to run
the task regardless of whether a user is logged on, select Run Whether
User Is Logged On Or Not. You can also elect to run with highest
privileges and configure the task for specified releases of Windows. To
configure the task for Windows 7 and Windows 8, choose Windows 7,
Windows Server 2008 R2.
-
On the Triggers tab, create and manage triggers by using the options
provided. To create a trigger, tap or click New, use the options
provided to configure the trigger, and then tap or click OK. -
On the Actions tab, create and manage actions by using the options
provided. To create an action, tap or click New, use the options
provided to configure the action, and then tap or click OK. -
On the Conditions tab, specify any limiting conditions for starting or stopping the task. -
On the Settings tab, choose any additional optional settings for the task. -
Tap or click OK to create the task.
Troubleshooting Scheduled Tasks
When you configure tasks to run on a computer, you can encounter
several types of problems. Some tasks won’t run when they are supposed
to. Others will start but won’t stop. To determine the status of a
task, select the task in the Task
Scheduler and note the status, last run time, and last run result. If a
task has a status of Queued, it is waiting to run at a scheduled time.
If a task has a status of Ready, it is ready to run at its next run
time. If a task should be running automatically but has a last run time
of Never, you need to check the task’s properties to determine why it
isn’t running. If the last run result is an error, you need to resolve
the referenced problem so that the task can run normally.
Check a task’s properties by tapping or clicking its entry in the Task
Scheduler. The History tab provides detailed information on the task,
from creation to its latest run time. Use the information to help you
resolve problems with the task.
A task that is listed as Running might not in fact be
running but instead might be a hung process. You can check for hung
processes by using the Last Run Time column, which tells you when the
task was started. If a task has been running for more than a day, there
is usually a problem. A script might be waiting for input, the task
might have problems reading or writing files, or the task might simply
be a runaway task that needs to be stopped. To stop the task, press and
hold or right-click it in the Task Scheduler, and then tap or click End.
|