/// <summary>The task will run on Sunday.</summary>
TASK_SUNDAY=0x1,
/// <summary>The task will run on Monday</summary>
TASK_MONDAY=0x2,
/// <summary>The task will run on Tuesday</summary>
TASK_TUESDAY=0x4,
/// <summary>The task will run on Wednesday</summary>
TASK_WEDNESDAY=0x8,
/// <summary>The task will run on Thursday</summary>
TASK_THURSDAY=0x10,
/// <summary>The task will run on Friday</summary>
TASK_FRIDAY=0x20,
/// <summary>The task will run on Saturday</summary>
TASK_SATURDAY=0x40,
}
/// <summary>
/// Options for a task, used for the Flags property of a Task. Uses the "Flags" attribute, so these values are combined with |. Some flags are documented
/// as Windows 95 only, but they have a user interface in Windows XP so that may not be true.
/// This flag is used when converting Windows NT AT service jobs into work items. The Windows NT AT service job refers to At.exe, the Windows NT
/// command-line utility used for creating jobs for the Windows NT Schedule service. The Task Scheduler service replaces the Schedule service and is
/// backward compatible with it. The conversion occurs when the Task Scheduler is installed on Windows NT/Windows 2000<30> for example, if you install
/// Internet Explorer 4.0, or upgrade to Windows 2000. During the setup process, the Task Scheduler installation code searches the registry for jobs
/// created for the AT service and creates work items that will accomplish the same operation. For such converted jobs, the interactive flag is set
/// if the work item is intended to be displayed to the user. When this flag is not set, no work items are displayed in the Tasks folder, and no user
/// interface associated with the work item is presented to the user when the work item is executed.
/// </summary>
TASK_FLAG_INTERACTIVE=0x1,
/// <summary>The work item will be deleted when there are no more scheduled run times.</summary>
TASK_FLAG_DELETE_WHEN_DONE=0x2,
/// <summary>The work item is disabled. This is useful to temporarily prevent a work item from running at the scheduled time(s).</summary>
TASK_FLAG_DISABLED=0x4,
/// <summary>The task runs only if the system is docked. Windows 95 only.</summary>
TASK_FLAG_RUN_ONLY_IF_DOCKED=0x100,
/// <summary>The work item created will be hidden.</summary>
TASK_FLAG_HIDDEN=0x200,
/// <summary>
/// The work item runs only if the user specified in IScheduledWorkItem::SetAccountInformation is logged on interactively. This flag has no effect on
/// the work items that are set to run in the local account.
/// </summary>
TASK_FLAG_RUN_ONLY_IF_LOGGED_ON=0x2000,
/// <summary>The work item begins only if the computer is not in use at the scheduled start time.</summary>
TASK_FLAG_START_ONLY_IF_IDLE=0x10,
/// <summary>
/// The work item causes the system to be resumed, or awakened, if the system is running on battery power. This flag is supported only on systems
/// that support resume timers.
/// </summary>
TASK_FLAG_SYSTEM_REQUIRED=0x1000,
/// <summary>
/// The work item terminates if the computer makes an idle to non-idle transition while the work item is running. The computer is not considered idle
/// until the IdleWait triggers' time elapses with no user input. For information regarding idle triggers, see Idle Trigger.
/// </summary>
TASK_FLAG_KILL_ON_IDLE_END=0x20,
/// <summary>
/// The work item starts again if the computer makes a non-idle to idle transition before all the work item's task_triggers elapse. (Use this flag in
/// conjunction with TASK_FLAG_KILL_ON_IDLE_END.)
/// </summary>
TASK_FLAG_RESTART_ON_IDLE_RESUME=0x800,
/// <summary>The work item does not start if its target computer is running on battery power.</summary>
TASK_FLAG_DONT_START_IF_ON_BATTERIES=0x40,
/// <summary>The work item ends, and the associated application quits if the work item's target computer switches to battery power.</summary>
TASK_FLAG_KILL_IF_GOING_ON_BATTERIES=0x80,
/// <summary>The work item runs only if there is currently a valid Internet connection.</summary>
TASK_FLAG_RUN_IF_CONNECTED_TO_INTERNET=0x400,
}
/// <summary>Value that describes the month(s) when the task runs.</summary>
[Flags]
publicenumTaskMonths:ushort
{
/// <summary>The task will run in January.</summary>
TASK_JANUARY=0x1,
/// <summary>The task will run in February</summary>
TASK_FEBRUARY=0x2,
/// <summary>The task will run in March</summary>
TASK_MARCH=0x4,
/// <summary>The task will run in April</summary>
TASK_APRIL=0x8,
/// <summary>The task will run in May</summary>
TASK_MAY=0x10,
/// <summary>The task will run in June</summary>
TASK_JUNE=0x20,
/// <summary>The task will run in July</summary>
TASK_JULY=0x40,
/// <summary>The task will run in August</summary>
TASK_AUGUST=0x80,
/// <summary>The task will run in September</summary>
TASK_SEPTEMBER=0x100,
/// <summary>The task will run in October</summary>
TASK_OCTOBER=0x200,
/// <summary>The task will run in November</summary>
TASK_NOVEMBER=0x400,
/// <summary>The task will run in December</summary>
TASK_DECEMBER=0x800,
}
/// <summary>
/// Status values returned for a task. Some values have been determined to occur although they do no appear in the Task Scheduler system documentation.
/// </summary>
publicenumTaskStatus:uint
{
/// <summary>The task is ready to run at its next scheduled time.</summary>
Ready=HRESULT.SCHED_S_TASK_READY,
/// <summary>The task is currently running.</summary>
Running=HRESULT.SCHED_S_TASK_RUNNING,
/// <summary>One or more of the properties that are needed to run this task on a schedule have not been set.</summary>
NotScheduled=HRESULT.SCHED_S_TASK_NOT_SCHEDULED,
/// <summary>The task has not yet run.</summary>
NeverRun=HRESULT.SCHED_S_TASK_HAS_NOT_RUN,
/// <summary>The task will not run at the scheduled times because it has been disabled.</summary>
Disabled=HRESULT.SCHED_S_TASK_DISABLED,
/// <summary>There are no more runs scheduled for this task.</summary>
NoMoreRuns=HRESULT.SCHED_S_TASK_NO_MORE_RUNS,
/// <summary>The last run of the task was terminated by the user.</summary>
Terminated=HRESULT.SCHED_S_TASK_TERMINATED,
/// <summary>Either the task has no triggers or the existing triggers are disabled or not set.</summary>
/// <summary>Event triggers don't have set run times.</summary>
NoTriggerTime=HRESULT.SCHED_S_EVENT_TRIGGER
}
/// <summary>Value that describes the behavior of the trigger. This value is a combination of the following flags.</summary>
[Flags]
publicenumTaskTriggerFlags:uint
{
/// <summary>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.</summary>
TASK_TRIGGER_FLAG_HAS_END_DATE=0x1,
/// <summary>
/// Task will be terminated at the end of the active trigger's lifetime. At the duration end, the Task Scheduler sends a WM_CLOSE message to the
/// associated application. If WM_CLOSE cannot be sent (for example, the application has no windows) or the application has not exited within three
/// minutes of the receiving WM_CLOSE, the Task Scheduler terminates the application using TerminateProcess.
/// </summary>
TASK_TRIGGER_FLAG_KILL_AT_DURATION_END=0x2,
/// <summary>Task trigger is inactive.</summary>
TASK_TRIGGER_FLAG_DISABLED=0x4
}
/// <summary>Specifies the week of the month when the task runs.</summary>
publicenumTaskWhichWeek:ushort
{
/// <summary>The task will run between the first and seventh day of the month.</summary>
TASK_FIRST_WEEK=1,
/// <summary>The task will run between the eighth and 14th day of the month.</summary>
TASK_SECOND_WEEK=2,
/// <summary>The task will run between the 15th and 21st day of the month.</summary>
TASK_THIRD_WEEK=3,
/// <summary>The task will run between the 22nd and 28th of the month.</summary>
TASK_FOURTH_WEEK=4,
/// <summary>The task will run between the last seven days of the month.</summary>
TASK_LAST_WEEK=5,
}
/// <summary>
/// Provides the methods for enumerating the tasks in the Scheduled Tasks folder.
/// <para>IEnumWorkItems is the primary interface of the enumeration object. To create the enumeration, call ITaskScheduler::Enum.</para>
/// Retrieves the next specified number of tasks in the enumeration sequence. If there are fewer than the requested number of tasks left in the
/// sequence, all the remaining elements are retrieved.
/// </summary>
/// <param name="celt">The number of tasks to retrieve.</param>
/// <param name="rgpwszNames">
/// A pointer to an array of pointers (LPWSTR) to null-terminated character strings containing the file names of the tasks returned from the
/// enumeration sequence. These file names are taken from the Scheduled Tasks folder and have the ".job" extension.
/// <para>
/// After processing the names returned in rgpwszNames, you must first free each character string in the array and then the array itself using CoTaskMemFree.
/// </para>
/// </param>
/// <param name="pceltFetched">A pointer to the number of tasks returned in rgpwszNames. If the celt parameter is 1, this parameter may be NULL.</param>
/// <returns></returns>
[PreserveSig]
//HRESULT Next([In] uint celt, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] out SafeCoTaskMemString[] rgpwszNames, [Out] out uint pceltFetched);
/// <summary>Deletes a trigger from a work item.</summary>
/// <param name="iTrigger">A trigger index value that specifies the trigger to be deleted. For more information, see Remarks.</param>
voidDeleteTrigger([In]ushortiTrigger);
/// <summary>Retrieves the number of triggers for the current work item.</summary>
/// <returns>A WORD that will contain the number of triggers associated with the work item.</returns>
[return: MarshalAs(UnmanagedType.U2)]
ushortGetTriggerCount();
/// <summary>Retrieves a task trigger.</summary>
/// <param name="iTrigger">The index of the trigger to retrieve.</param>
/// <returns>An ITaskTrigger interface for the retrieved trigger.</returns>
[return: MarshalAs(UnmanagedType.Interface)]
ITaskTriggerGetTrigger([In]ushortiTrigger);
/// <summary>Retrieves a string that describes the work item trigger.</summary>
/// <param name="iTrigger">The index of the trigger to be retrieved. The first trigger is always referenced by 0. For more information, see Remarks.</param>
/// <returns>
/// A pointer to a null-terminated string that contains the retrieved trigger description. Note that this string must be release by a call to
/// CoTaskMemFree after the string is no longer needed.
/// <summary>Retrieves the work item run times for a specified time period.</summary>
/// <param name="pstBegin">A pointer to a SYSTEMTIME structure that contains the starting time of the time period to check. This value is inclusive.</param>
/// <param name="pstEnd">
/// A pointer to a SYSTEMTIME structure that contains the ending time of the time period to check. This value is exclusive. If NULL is passed for
/// this value, the end time is infinite.
/// </param>
/// <param name="pCount">
/// A pointer to a WORD value that specifies the number of run times to retrieve.
/// <para>On input, this parameter contains the number of run times being requested. This can be a number of between 1 and TASK_MAX_RUN_TIMES.</para>
/// <para>On output, this parameter contains the number of run times retrieved.</para>
/// </param>
/// <returns>
/// A pointer to an array of SYSTEMTIME structures. A NULL LPSYSTEMTIME object should be passed into this parameter. On return, this array contains
/// pCount run times. You must free this array by a calling the CoTaskMemFree function.
/// <summary>Retrieves the idle wait time for the work item. For information about idle conditions, see Task Idle Conditions.</summary>
/// <param name="wIdleMinutes">A pointer to a WORD that contains the idle wait time for the current work item, in minutes.</param>
/// <param name="wDeadlineMinutes">
/// A pointer to a WORD that specifies the maximum number of minutes that the Task Scheduler will wait for the idle-time period returned in pwIdleMinutes.
/// <summary>Sets the number of times Task Scheduler will try to run the work item again if an error occurs. This method is not implemented.</summary>
/// <param name="wRetryCount">A value that specifies the number of error retries for the current work item.</param>
voidSetErrorRetryCount([In]ushortwRetryCount);
/// <summary>Retrieves the number of times that the Task Scheduler will retry an operation when an error occurs. This method is not implemented.</summary>
/// <returns>A pointer to a WORD that contains the number of times to retry.</returns>
ushortGetErrorRetryCount();
/// <summary>
/// Sets the time interval, in minutes, between Task Scheduler's attempts to run a work item after an error occurs. This method is not implemented.
/// </summary>
/// <param name="wRetryInterval">A value that specifies the interval between error retries for the current work item, in minutes.</param>
/// <summary>This method sets the flags that modify the behavior of a scheduled task.</summary>
/// <param name="dwFlags">Currently, there are no flags defined for scheduled tasks.</param>
voidSetTaskFlags([In]uintdwFlags);
/// <summary>This method returns the flags that modify the behavior of a task.</summary>
/// <returns>Currently, there are no defined flags for scheduled tasks.</returns>
uintGetTaskFlags();
/// <summary>This method sets the maximum time the task can run, in milliseconds, before terminating.</summary>
/// <param name="dwMaxRunTime">
/// A DWORD value that specifies the maximum run time (in milliseconds), for the task. This parameter may be set to INFINITE to specify an unlimited time.
/// </param>
voidSetMaxRunTime([In]uintdwMaxRunTime);
/// <summary>This method retrieves the maximum length of time, in milliseconds, the task can run before terminating.</summary>
/// <returns>
/// A pointer to a DWORD that contains the maximum run time of the current task. If the maximum run time is reached during the execution of a task,
/// the Task Scheduler first sends a WM_CLOSE message to the associated application. If the application does not exit within three minutes,
/// TerminateProcess is run.
/// </returns>
uintGetMaxRunTime();
}
/// <summary>Provides the methods for scheduling tasks.</summary>
/// Provides the methods for accessing and setting triggers for a task. Triggers specify task start times, repetition criteria, and other parameters that
/// control when a task is run.
/// <para>ITaskTrigger is the primary interface of the task_trigger object. To create a trigger object, call CreateTrigger or GetTrigger.</para>
/// <para>[<c>GetNetScheduleAccountInformation</c> is no longer available for use as of Windows 8. Instead, use the Task Scheduler 2.0 Interfaces.]</para>
/// <para>The <c>GetNetScheduleAccountInformation</c> function retrieves the AT Service account name.</para>
/// </summary>
/// <param name="pwszServerName">A NULL-terminated wide character string for the name of the computer whose account information is being retrieved.</param>
/// <param name="ccAccount">
/// The number of characters, including the NULL terminator, allocated for wszAccount. The maximum allowed length for this value is the maximum domain
/// name length plus the maximum user name length plus 2, expressed as DNLEN + UNLEN + 2. (The last two characters are the "\" character and the NULL terminator.)
/// </param>
/// <param name="wszAccount">An array of wide characters, including the NULL terminator, that receives the account information.</param>
/// <returns>
/// The return value is an HRESULT. A value of S_OK indicates the function succeeded, and the account information is returned in wszAccount. A value of
/// S_FALSE indicates the function succeeded, and the account is the Local System account (no information will be returned in wszAccount). Any other
/// <para>[<c>SetNetScheduleAccountInformation</c> is no longer available for use as of Windows 8. Instead, use the Task Scheduler 2.0 Interfaces.]</para>
/// <para>
/// The <c>SetNetScheduleAccountInformation</c> function sets the AT Service account name and password. The AT Service account name and password are used
/// as the credentials for scheduled jobs created with <c>NetScheduleJobAdd</c>.
/// </para>
/// </summary>
/// <param name="pwszServerName">A NULL-terminated wide character string for the name of the computer whose account information is being set.</param>
/// <param name="pwszAccount">
/// A pointer to a NULL-terminated wide character string for the account. To specify the local system account, set this parameter to <c>NULL</c>.
/// </param>
/// <param name="pwszPassword">
/// A pointer to a NULL-terminated wide character string for the password. For information about securing password information, see Handling Passwords.
/// </param>
/// <returns>
/// <para>
/// The return value is an HRESULT. A value of S_OK indicates the account name and password were successfully set. Any other value indicates an error condition.
/// </para>
/// <para>If the function fails, some of the possible return values are listed below.</para>
/// <para>
/// <list type="table">
/// <listheader>
/// <term>Return code/value</term>
/// <term>Description</term>
/// </listheader>
/// <item>
/// <term>E_ACCESSDENIED0x080070005</term>
/// <term>
/// Access was denied. This error is returned if the caller was not a member of the Administrators group. This error is also returned if the pwszAccount
/// parameter was not NULL indicating a named account not the local system account and the pwszPassword parameter was incorrect for the account specified
/// Unable to establish existence of the account specified. This error is returned if the pwszAccount parameter was not NULL indicating a named account
/// not the local system account and the pwszAccount parameter could not be found.
/// Specifies the day of the month a task runs. This value is a bitfield 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.
/// </summary>
publicuintDays;
/// <summary>
/// Specifies the month(s) when the task runs. This value is a combination of the following flags. See Remarks for an example of setting multiple flags.
/// </summary>
publicTaskMonthsMonths;
}
/// <summary>Defines the date(s) that the task runs by month, week, and day of the week.</summary>
/// <summary>Specifies the week of the month when the task runs. This value is exclusive and is one of the following flags.</summary>
publicTaskWhichWeekwWhichWeek;
/// <summary>Specifies the day(s) of the week (specified in wWhichWeek) when the task runs. This value is a combination of the following flags.</summary>
publicTaskDaysOfTheWeekrgfDaysOfTheWeek;
/// <summary>Value that describes the month(s) when the task runs. This value is a combination of the following flags.</summary>
publicTaskMonthsrgfMonths;
}
/// <summary>Defines the times to run a scheduled work item.</summary>
/// <summary>Size of this structure, in bytes.</summary>
publicushortcbTriggerSize;
/// <summary>For internal use only; this value must be zero.</summary>
publicushortReserved1;
/// <summary>
/// Year that the task trigger activates. This value must be four digits (1997, not 97). The beginning year must be specified when setting a task.
/// </summary>
publicushortwBeginYear;
/// <summary>
/// Month of the year (specified in the wBeginYear member) that the task trigger activates. The beginning month must be specified when setting a task.
/// </summary>
publicushortwBeginMonth;
/// <summary>
/// Day of the month (specified in the wBeginMonth member) that the task trigger activates. The beginning day must be specified when setting a task.
/// </summary>
publicushortwBeginDay;
/// <summary>Year that the task trigger deactivates. This value must be four digits (1997, not 97).</summary>
publicushortwEndYear;
/// <summary>Month of the year (specified in the wEndYear member) that the task trigger deactivates.</summary>
publicushortwEndMonth;
/// <summary>Day of the month (specified in the wEndMonth member) that the task trigger deactivates.</summary>
publicushortwEndDay;
/// <summary>Hour of the day the task runs. This value is on a 24-hour clock; hours go from 00 to 23.</summary>
publicushortwStartHour;
/// <summary>Minute of the hour (specified in the wStartHour member) that the task runs.</summary>
publicushortwStartMinute;
/// <summary>
/// Number of minutes after the task starts that the trigger will remain active. The number of minutes specified here must be greater than or equal
/// to the MinutesInterval setting.
/// <para>
/// 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.
/// </para>
/// </summary>
publicuintMinutesDuration;
/// <summary>
/// Number of minutes between consecutive task executions. This number is counted from the start of the previous scheduled task. The number of
/// minutes specified here must be less than the MinutesDuration setting.
/// <para>For example, to run a task every hour from 8:00 A.M. to 5:00 P.M., set this field to 60.</para>
/// </summary>
publicuintMinutesInterval;
/// <summary>Value that describes the behavior of the trigger. This value is a combination of the following flags.</summary>
publicTaskTriggerFlagsrgFlags;
/// <summary>
/// A TASK_TRIGGER_TYPE enumerated value that specifies the type of trigger. This member is used with Type. The type of trigger specified here
/// determines which fields of the TRIGGER_TYPE_UNION specified in Type member will be used. Trigger type is based on when the trigger will run the task.
/// </summary>
publicTASK_TRIGGER_TYPETriggerType;
/// <summary>
/// A TRIGGER_TYPE_UNION structure that specifies details about the trigger. Note that the TriggerType member determines which fields of the
/// TRIGGER_TYPE_UNION union will be used.
/// </summary>
publicTRIGGER_TYPE_UNIONType;
/// <summary>For internal use only; this value must be zero.</summary>
publicushortReserved2;
/// <summary>Not currently used.</summary>
publicushortwRandomMinutesInterval;
/// <summary>Gets or sets the begin date.</summary>