Structures

Structures


This section describes the Task Scheduler structures.

DAILY

typedef struct _DAILY {
    WORD DaysInterval;
} DAILY;

Defines the interval, in days, between invocations of a task. The TRIGGER_TYPE_UNION union uses an instance of this structure as part of the TASK_TRIGGER structure definition.

DaysInterval
Number of days between invocations of a task.

MONTHLYDATE

typedef struct _MONTHLYDATE {
    DWORD rgfDays;
    WORD rgfMonths;
} MONTHLYDATE;

Defines the day of the month the task will run. The TRIGGER_TYPE_UNION union uses an instance of this structure as part of the TASK_TRIGGER structure definition.

rgfDays
Value that describes the day of the month a task runs. This value is a bit field that specifies the day(s) the task will run. Bit 0 corresponds to the first of the month, bit 1 to the second, and so forth.
rgfMonths
Value that describes the month(s) when the task runs. This value is a combination of the following flags:
TASK_JANUARY Task will run in January.
TASK_FEBRUARY Task will run in February.
TASK_MARCH Task will run in March.
TASK_APRIL Task will run in April.
TASK_MAY Task will run in May.
TASK_JUNE Task will run in June.
TASK_JULY Task will run in July.
TASK_AUGUST Task will run in August.
TASK_SEPTEMBER Task will run in September.
TASK_OCTOBER Task will run in October.
TASK_NOVEMBER Task will run in November.
TASK_DECEMBER Task will run in December.

The following code fragment provides an example of how you can combine these flags. This example would run a task quarterly.

MONTHLYDATE example;
example.rgfDays = 1;
example.rgfMonths = TASK_JANUARY | TASK_APRIL | TASK_JULY | TASK_OCTOBER;

MONTHLYDOW

typedef struct _MONTHLYDOW {
    WORD wWhichWeek;
    WORD rgfDaysOfTheWeek;
    WORD rgfMonths;
} MONTHLYDOW;

(MONTHLY Day Of the Week) Defines the date(s) that the task runs by month, week, and day of week. The TRIGGER_TYPE_UNION union uses an instance of this structure as part of the TASK_TRIGGER structure definition.

wWhichWeek
Value that describes the week of the month when the task runs. This value is exclusive and is one of the following flags:
TASK_FIRST_WEEK Task will run during the first week of the month.
TASK_SECOND_WEEK Task will run during the second week of the month.
TASK_THIRD_WEEK Task will run during the third week of the month.
TASK_FOURTH_WEEK Task will run during the fourth week of the month.
TASK_LAST_WEEK Task will run during the last week of the month.
rgfDaysOfTheWeek
Value that describes the day(s) of the week specified in wWhichWeek when the task runs. This value is a combination of the following flags:
TASK_SUNDAY Task will run on Sunday.
TASK_MONDAY Task will run on Monday.
TASK_TUESDAY Task will run on Tuesday.
TASK_WEDNESDAY Task will run on Wednesday.
TASK_THURSDAY Task will run on Thursday.
TASK_FRIDAY Task will run on Friday.
TASK_SATURDAY Task will run on Saturday.
rgfMonths
Value that describes the month(s) when the task runs. This value is a combination of the following flags:
TASK_JANUARY Task will run in January.
TASK_FEBRUARY Task will run in February.
TASK_MARCH Task will run in March.
TASK_APRIL Task will run in April.
TASK_MAY Task will run in May.
TASK_JUNE Task will run in June.
TASK_JULY Task will run in July.
TASK_AUGUST Task will run in August.
TASK_SEPTEMBER Task will run in September.
TASK_OCTOBER Task will run in October.
TASK_NOVEMBER Task will run in November.
TASK_DECEMBER Task will run in December.

The following code fragment provides an example of how you can combine these flags. This example would run a task on Monday and Friday of the third week of every third month.

MONTHLYDOW example;
example.wWhichWeek = TASK_THIRD_WEEK;
example.rgfDaysOfTheWeek = TASK_FRIDAY | TASK_MONDAY;
example.rgfMonths = TASK_JANUARY | TASK_APRIL | TASK_JULY | TASK_OCTOBER;

TASK_TRIGGER

typedef struct _TASK_TRIGGER {
    WORD cbTriggerSize; 
    WORD Reserved1;
    WORD wBeginYear;            
    WORD wBeginMonth;           
    WORD wBeginDay;             
    WORD wEndYear;              
    WORD wEndMonth;             
    WORD wEndDay;               
    WORD wStartHour;            
    WORD wStartMinute;          
    DWORD MinutesDuration;      
    DWORD MinutesInterval;      
    DWORD rgFlags;              
    TASK_TRIGGER_TYPE TriggerType;
    TRIGGER_TYPE_UNION Type;
    WORD Reserved2;
    WORD wRandomMinutesInterval;
} TASK_TRIGGER, * PTASK_TRIGGER;

Defines the start time, end time, duration, and modification flags for a task.

cbTriggerSize
Size of this structure, in bytes (sizeof(TASK_TRIGGER)).
Reserved1
For internal use only; this value must be zero.
wBeginYear
Year that the task trigger activates. This value must be four digits (1997, not 97).
wBeginMonth
Month of the year in the wBeginYear member that the task trigger activates.
wBeginDay
Day of the month in the wBeginMonth member that the task trigger activates.
wEndYear
Year that the task trigger deactivates. This value must be four digits (1997, not 97).
wEndMonth
Month of the year in the wEndYear member that the task trigger deactivates.
wEndDay
Day of the month in the wEndMonth member that the task trigger deactivates.
wStartHour
Hour of the day the task runs. This value is on a 24-hour clock; hours go from 00 to 23.
wStartMinute
Minute of the hour in the wStartHour member that the task runs.
MinutesDuration
Number of minutes after the task starts that the trigger will remain active. For example, if you start a task at 8:00 A.M. and want to repeatedly start the task until 5:00 P.M., there would be 540 minutes in the duration.
MinutesInterval
Number of minutes between consecutive task executions. This number is counted from the start of the previous task. For example, to run a task every hour from 8:00 A.M. to 5:00 P.M., set this field to 60.
rgFlags
Value that describes the task trigger's behavior. This value is a combination of the following flags:
TASK_TRIGGER_FLAG_HAS_END_DATE
Trigger structure's end date is valid. If this flag is not set, the end date data is ignored and the trigger will be valid indefinitely.
TASK_TRIGGER_FLAG_KILL_AT_DURATION_END
Task will be terminated at the end of the active trigger's lifetime. At the duration end, the scheduling agent first sends a WM_CLOSE message to the associated application. If the application hasn't exited in three minutes, TerminateProcess runs. If more than one instance of a task is running, all instances are terminated.
TASK_TRIGGER_FLAG_DISABLED
Task trigger is inactive.
TriggerType
Value that determines the type of trigger for this task. This value is a member of the TASK_TRIGGER_TYPE enumerated type.
Type
Structure that determines the type of trigger for this task. This structure is a member of the TRIGGER_TYPE_UNION union.
Reserved2
For internal use only; this value must be zero.
wRandomMinutesInterval
Not currently used.

WEEKLY

typedef struct _WEEKLY {
    WORD WeeksInterval;
    WORD rgfDaysOfTheWeek;
} WEEKLY;

Defines the interval, in weeks, between invocations of a task. The TRIGGER_TYPE_UNION union uses an instance of this structure as part of the TASK_TRIGGER structure definition.

WeeksInterval
Number of weeks between invocations of a task.
rgfDaysOfTheWeek
Value that describes the days of the week the task runs. This value is a bit field and is a combination of the following flags:
TASK_SUNDAY Task will run on Sunday.
TASK_MONDAY Task will run on Monday.
TASK_TUESDAY Task will run on Tuesday.
TASK_WEDNESDAY Task will run on Wednesday.
TASK_THURSDAY Task will run on Thursday.
TASK_FRIDAY Task will run on Friday.
TASK_SATURDAY Task will run on Saturday.

The following code fragment provides an example of how you can combine these flags. This example would run a task on every other Sunday, Wednesday, and Friday.

WEEKLY example;
example.WeeksInterval = 2;
example.rgfDaysOfTheWeek = TASK_SUNDAY | TASK_WEDNESDAY | TASK_FRIDAY;

© 1997 Microsoft Corporation. All rights reserved. Terms of Use.