8. Scheduled Tasks Events
In
Windows Server 2003 and earlier versions of the Windows operating
system, scheduled tasks used a Schedlgu.txt log file to track tasks and
their status. Windows Vista implements all new event logs for
applications and Task Scheduler now logs all operational information
about scheduled tasks into its own event log. The Scheduled Tasks event
log Microsoft-Windows-TaskScheduler is located under Application Logs.
Important errors or warnings about task or service failures are logged
to the System log so that administrators can readily see them and take
action.
The Windows Vista Scheduled Tasks component will
normally log an event on task registration (at creation), at task
launch, and when the task instance has been sent to the engine. Events
will also be logged on task failures and any task-related problems.
This section provides examples of typical events that are logged by the Scheduled Tasks service.
Task Registration
An Event ID 106 is logged when a task is created. This event is also referred to as task registration.
Task Launch
Tasks can be launched by either a user request
or by a trigger. An Event ID 110 is normally logged when a user manually
launches a task. An Event ID 107 is normally logged when a task is
launched as the result of a trigger.
Task Execution
An Event ID 319 indicates that the Task Engine
received a message from the Task Scheduler service requesting task
launch, and is the best indicator of a task launch. In these events, the
Task Engine is identified by the user SID, and the task name is also
logged.
Task Completion
An Event ID 102 is normally logged when a task completes successfully.
9. Troubleshooting Task Scheduler
Task or service failures are logged to the
system event log. It is important to note that the events will vary and
be based on what specifically failed. A user will see different events
based on whether a task failed to start, or if the task started
successfully but the action failed.
The key to troubleshooting Task Scheduler is
understanding specifically where the failure occurred in the process. A
task is defined as an action, the trigger for the action, the conditions
under which the task will run, and additional settings. The event log
will show if the failure is in the trigger, the task action, the
conditions, or the settings of the task.
Tasks Won’t Run If the Service Is Not Started
If you are having problems scheduling tasks or
getting tasks to run correctly, first ensure that the Task Scheduler
service is running. You can run services.msc to verify that the Task
Scheduler service status is Started.
The Task Did Not Run at the Expected Time
If a scheduled task does not run when you
expect it to run, ensure that the task is enabled, and also check the
triggers on the task to ensure that they are set correctly. Also, check
the history of the task, as shown in Figure 5, to see when the task was started and check for errors.
The Task Will Run Only If All Conditions Are Met
You can set task conditions on the Conditions
tab of the Task Properties dialog box. If conditions are not met or are
set up incorrectly, the task will not execute.
The Task Will Only Run When a Certain User Is Logged On
If a scheduled task
does not run when you expect it to run, review the Security Options
settings in the Task Properties dialog box on the General tab.
The Task Executed a Program But the Program Did Not Run Correctly
If a task attempts to execute a program, but
the program does not run correctly, first try running the program
manually (not from a task) to ensure that the program works correctly.
You may need to add arguments to the program command or define the Start
In path using the Add Arguments and/or Start In optional fields.
The Task Failed to Start
An Event ID 101 is normally logged when a task
fails to start. In these events, the result code is also displayed. For
more information about result and return codes, see “Interpreting Result and Return Codes” later in this section.
The Task Action Failed to Execute
When a task starts but the action configured
for the task fails to execute, an Event ID 103 or an Event ID 203 is
normally logged. These events also display the return code. For more
information about result and return codes, see “Interpreting Result and Return Codes” later in this section.
The Program Specified in the Task Requires Elevated Privileges
If a task is running a program that requires
elevated privileges, ensure that the task runs with the highest
privileges. You can set a task to run with the highest privileges by
changing the task’s security options on the General tab of the Task
Properties dialog box.
Interpreting Result and Return Codes
To interpret return codes, you can use a tool
such as Err.exe, which you can obtain from the Microsoft Download
Center. Err,exe parses source-code header files until it finds a match
for the error. In this regard, the Scheduled Tasks service in Windows
Vista still functions quite similarly to previous versions of Windows.
Return codes from events that occur internally are always translated
into hresult code. For example, the login failed event will contain a
result code that can be interpreted as a hresult. Task handler tasks
also return result codes that you can interpret using the same tools.
However, when an executable is launched
and fails for an unknown reason, you have no way of knowing what the
result code might mean. The hresult logged in the event log will
typically indicate the value returned to the service from the executable
itself, and additional research and documentation may be required for
accurately interpreting the code.