2.2.1.18.1 Task Inner Element

The Task element shares a number of attributes with the ImmediateTask element. The shared attributes are defined in the table that follows.

Attribute name

Description

action

(optional) If specified, the value MUST be C, D, R, or U, corresponding to Create, Delete, Replace, and Update. If unspecified, the default value is U.

  • Create: This action MUST be used to create a new scheduled task for users or computers.

  • Delete: This action MUST be used to remove a scheduled task for users or computers.

  • Replace: This action MUST be used to delete and recreate scheduled tasks for users or computers. The net result of the Replace action is to overwrite all existing settings associated with the scheduled task. If the scheduled task does not exist, the Replace action creates a new scheduled task.

  • Update: This action MUST be used to modify settings of an existing scheduled task for users or computers. This action differs from Replace in that it updates only settings defined within the preference item. All other settings remain as configured in the scheduled task. If the scheduled task does not exist, the Update action creates a new scheduled task.

name

Sets a name for the scheduled task. This name appears in the list of scheduled tasks in Control Panel for users or computers. To modify or delete a task, this name MUST match the name of the existing task as it appears in Control Panel for computers or users. Scheduled tasks and immediate tasks with the same name will not conflict.

appName

Sets the command to be run, not including any arguments. This field applies only if the action selected is Create, Replace, or Update.

args

(optional) Sets any command-line arguments required. This field applies only if the action selected is Create, Replace, or Update.

startIn

(optional) Sets the working directory used for the task when launched. Do not include quotation marks or a trailing slash. This field applies only if the action selected is Create, Replace, or Update.

comment

(optional) Sets a description of the task. This description will be visible for users or computers to which this preference item is applied. This field applies only if the action selected is Create, Replace, or Update.

runAs

(optional) Configures the security context under which the task is run. If the preference item is part of Computer Configuration, by default the task is run in the security context of the Task Scheduler service, which is typically the System account. If the preference item is part of User Configuration, by default the task is run in the security context of the user that is logged on. The task is run only if the user is logged on to the computer but can continue after the user logs off. To run a task under the security context of a specified account (enabling the task to run whether or not that account is logged on), set the Run as option, and set credentials for the account. These fields apply only if the action selected is Create, Replace, or Update.

cpassword

(optional) The password of the runAs credentials. The password is encrypted using an AES key when the preference item is created.

enabled

Sets this option so that the task runs. To configure the task for users or computers without allowing it to run, clear this option. This option applies only if the action selected is Create, Replace, or Update.

deleteWhenDone

(optional) MUST be 1 to indicate that the task remains after completion, and 0 to indicate that it does not.

maxRunTime

 (optional) MUST be the number of seconds that the job is allowed to run.

startOnlyIfIdle

(optional) MUST be 1 to indicate that the job will execute only if the machine is currently idle, and 0 to indicate that it will execute regardless of the machine's idle state.

idleMinutes

(optional) MUST be the number of minutes during which the system is not idle before the task is canceled.

deadlineMinutes

(optional) MUST be the number of minutes in which the task is allowed to be active.

stopOnIdleEnd

(optional) MUST be 1 to indicate that the task will terminate if the system becomes active, and 0 to indicate that it does not terminate.

noStartIfOnBatteries

(optional) MUST be 1 to indicate that the task will run only if running on AC power, and 0 to indicate that it will run regardless of the power type.

stopIfGoingOnBatteries

(optional) MUST be 1 to indicate that the task will terminate if AC power is disconnected, and 0 to indicate that it does not terminate.

systemRequired

(optional) MUST be 1 to indicate that the task executes from a local Administrator account, and 0 to indicate that an Administrator account is not necessary for the task to run.

Each task can have one or more triggers that define when the task runs and various attributes of the task. These attributes are not shared with the ImmediateTask element.

Attribute name

Description

type

(required) MUST be IDLE, ONCE, STARTUP, LOGON, DAILY, WEEKLY, or MONTHLY to indicate the frequency of the task processing.

startHour

(optional) MUST be the UTC hour in which the task will start.

startMinutes

(optional) MUST be the UTC minute in which the task will start.

beginYear

(optional) MUST be the year, using four digits, that the task will start.

beginMonth

(optional) MUST be the month that the task will start.

beginDay

(optional) MUST be the day that the task will start.

hasEndDate

(optional) MUST be 0 to indicate that the task has no end date, or 1 to indicate that the task is not scheduled beyond the end date.

repeatTask

(optional) MUST be 0 to indicate that the task repeats, or 1 to indicate that the task does not repeat.

interval

(optional) MUST be the numeric interval between task executions. The unit of measure is based on the type so it is expressed in days, weeks, or months.

days

(optional) MUST map to the day of the week in which the job will process for jobs that execute on a selected day. The field is a bit mask with 1 assigned to Sunday, 2 to Monday, 4 to Tuesday, 8 to Wednesday, 16 to Thursday, 32 to Friday, and 64 to Saturday.

months

(optional) MUST map to the month in which a job will process. The field is a 12-bit mask with 1 assigned to January, 2 to February, 4 to March, 8 to April, 16 to May, 32 to June, 64 to July, 128 to August, 256 to September, 512 to October, 1024 to November, and 2048 to December.

week

(optional) MUST be FIRST, SECOND, THIRD, FOURTH, or LAST to indicate the week position in the month when the task executes.

idleMinute

(optional) MUST specify the time, in minutes, that the system remains idle before the task can run.

endYear

(optional) MUST specify the time, in minutes, that the task will wait for the idle period specified in idleMinute.

endMonth

(optional) MUST specify the end month for the task to complete if an end date is specified.

endDay

(optional) MUST specify the end day for the task to complete if an end date is specified.

minutesInterval

(optional) MUST be the number of minutes between consecutive task executions.

killAtDurationEnd

(optional) MUST be 1 to specify that the task is terminated at the end of the trigger's lifetime.

minutesDuration

(optional) MUST be the number of minutes after the task starts that the task remains active.

Show: