//+---------------------------------------------------------------------------- // // Task Scheduler // // Microsoft Windows // Copyright 1992 - 1998 Microsoft Corporation. // // File: mstask.idl // // Contents: ITaskTrigger, ITask, ITaskScheduler, IEnumTasks // interfaces and related definitions // // History: 06-Sep-95 EricB created // // 14-April-2000 Marina Nudelman, ISE. // Modified to make EiffelCOM wizard friendly. // //----------------------------------------------------------------------------- import "oaidl.idl"; import "oleidl.idl"; // 148BD520-A2AB-11CE-B11F-00AA00530503 - Task object class ID // 148BD52A-A2AB-11CE-B11F-00AA00530503 - Task Scheduler class ID // A6B952F0-A4B1-11D0-997D-00AA006887EC - IScheduledWorkItem interface ID // 148BD524-A2AB-11CE-B11F-00AA00530503 - ITask interface ID // 148BD527-A2AB-11CE-B11F-00AA00530503 - ITaskScheduler interface ID // 148BD528-A2AB-11CE-B11F-00AA00530503 - IEnumTasks interface ID // 148BD52B-A2AB-11CE-B11F-00AA00530503 - ITaskTrigger interface ID //+---------------------------------------------------------------------------- // // Datatypes // //----------------------------------------------------------------------------- typedef enum tagTASK_WEEK_DAY { TASK_SUNDAY = (0x1), TASK_MONDAY = (0x2), TASK_TUESDAY = (0x4), TASK_WEDNESDAY = (0x8), TASK_THURSDAY = (0x10), TASK_FRIDAY = (0x20), TASK_SATURDAY = (0x40) } TASK_WEEK_DAY; typedef enum tagTASK_MONTH_WEEK { TASK_FIRST_WEEK = (1), TASK_SECOND_WEEK = (2), TASK_THIRD_WEEK = (3), TASK_FOURTH_WEEK = (4), TASK_LAST_WEEK = (5) } TASK_MONTH_WEEK; typedef enum tagTASK_MONTH { TASK_JANUARY = (0x1), TASK_FEBRUARY = (0x2), TASK_MARCH = (0x4), TASK_APRIL = (0x8), TASK_MAY = (0x10), TASK_JUNE = (0x20), TASK_JULY = (0x40), TASK_AUGUST = (0x80), TASK_SEPTEMBER = (0x100), TASK_OCTOBER = (0x200), TASK_NOVEMBER = (0x400), TASK_DECEMBER = (0x800) } TASK_MONTH; typedef enum tagTASK_FLAG { TASK_FLAG_INTERACTIVE = (0x1), TASK_FLAG_DELETE_WHEN_DONE = (0x2), TASK_FLAG_DISABLED = (0x4), TASK_FLAG_START_ONLY_IF_IDLE = (0x10), TASK_FLAG_KILL_ON_IDLE_END = (0x20), TASK_FLAG_DONT_START_IF_ON_BATTERIES = (0x40), TASK_FLAG_KILL_IF_GOING_ON_BATTERIES = (0x80), TASK_FLAG_RUN_ONLY_IF_DOCKED = (0x100), TASK_FLAG_HIDDEN = (0x200), TASK_FLAG_RUN_IF_CONNECTED_TO_INTERNET = (0x400), TASK_FLAG_RESTART_ON_IDLE_RESUME = (0x800), TASK_FLAG_SYSTEM_REQUIRED = (0x1000) } TASK_FLAG; typedef enum tagTASK_TRIGGER_FLAG { TASK_TRIGGER_FLAG_HAS_END_DATE = (0x1), TASK_TRIGGER_FLAG_KILL_AT_DURATION_END = (0x2), TASK_TRIGGER_FLAG_DISABLED = (0x4) } TASK_TRIGGER_FLAG; // // 1440 = 60 mins/hour * 24 hrs/day since a trigger/TASK could run all day at // one minute intervals. // const int TASK_MAX_RUN_TIMES = 1440; [helpstring ("Used to specify the type of trigger for a task.")] typedef enum _TASK_TRIGGER_TYPE { TASK_TIME_TRIGGER_ONCE = 0, TASK_TIME_TRIGGER_DAILY = 1, TASK_TIME_TRIGGER_WEEKLY = 2, TASK_TIME_TRIGGER_MONTHLYDATE = 3, TASK_TIME_TRIGGER_MONTHLYDOW = 4, TASK_EVENT_TRIGGER_ON_IDLE = 5, TASK_EVENT_TRIGGER_AT_SYSTEMSTART = 6, TASK_EVENT_TRIGGER_AT_LOGON = 7 } TASK_TRIGGER_TYPE, *PTASK_TRIGGER_TYPE; [helpstring ("Defines the interval, in days, between invocations of a task.")] typedef struct _DAILY { WORD DaysInterval; } DAILY; [helpstring ("Defines the interval, in weeks, between invocations of a task.")] typedef struct _WEEKLY { WORD WeeksInterval; TASK_WEEK_DAY rgfDaysOfTheWeek; } WEEKLY; [helpstring ("Defines the day of the month the task will run.")] typedef struct _MONTHLYDATE { DWORD rgfDays; TASK_MONTH rgfMonths; } MONTHLYDATE; [helpstring ("Defines the date(s) that the task runs by month, week, and day of the week.")] typedef struct _MONTHLYDOW { TASK_MONTH_WEEK wWhichWeek; TASK_WEEK_DAY rgfDaysOfTheWeek; TASK_MONTH rgfMonths; } MONTHLYDOW; [helpstring ("Defines the invocation schedule of the trigger.")] typedef union _TRIGGER_TYPE_UNION { DAILY daily_interval; WEEKLY weekly_interval; MONTHLYDATE monthlyd_date; MONTHLYDOW monthly_DOW; } TRIGGER_TYPE_UNION; [helpstring ("Defines the times to run a scheduled work item.")] typedef struct _TASK_TRIGGER { [helpstring ("Structure size.")] WORD cbTriggerSize; [helpstring ("Reserved. Must be zero.")] WORD Reserved1; [helpstring ("Trigger beginning date year.")] WORD wBeginYear; [helpstring ("Trigger beginning date month.")] WORD wBeginMonth; [helpstring ("Trigger beginning date day.")] WORD wBeginDay; [helpstring ("Optional trigger ending date year.")] WORD wEndYear; [helpstring ("Optional trigger ending date month.")] WORD wEndMonth; [helpstring ("Optional trigger ending date day.")] WORD wEndDay; [helpstring ("Run bracket start time hour.")] WORD wStartHour; [helpstring ("Run bracket start time minute.")] WORD wStartMinute; [helpstring ("Duration of run bracket.")] DWORD MinutesDuration; [helpstring ("Run bracket repetition interval.")] DWORD MinutesInterval; [helpstring ("Trigger flags.")] DWORD rgFlags; [helpstring ("Trigger type.")] TASK_TRIGGER_TYPE TriggerType; [helpstring ("Trigger data.")] TRIGGER_TYPE_UNION Type; [helpstring ("Reserved. Must be zero.")] WORD Reserved2; [helpstring ("Maximum number of random minutes after start time.")] WORD wRandomMinutesInterval; } TASK_TRIGGER, * PTASK_TRIGGER; //+---------------------------------------------------------------------------- // // Interfaces // //----------------------------------------------------------------------------- [ local, object, uuid(148BD52B-A2AB-11CE-B11F-00AA00530503), helpstring("Trigger object interface. A Task object may contain several of these."), pointer_default(unique) ] interface ITaskTrigger : IUnknown { // Methods: [helpstring ("Sets the task trigger values.")] HRESULT SetTrigger( [in] const PTASK_TRIGGER pTrigger); [helpstring ("Retrieves the current task trigger.")] HRESULT GetTrigger( [out] PTASK_TRIGGER pTrigger); [helpstring ("Retrieves the current task trigger in the form of a string.")] HRESULT GetTriggerString( [out] LPWSTR * ppwszTrigger); }; [ local, object, uuid(a6b952f0-a4b1-11d0-997d-00aa006887ec), helpstring("Abstract base class for any runnable work item that can be scheduled by the task scheduler."), pointer_default(unique) ] interface IScheduledWorkItem : IUnknown { // Methods concerning scheduling: [helpstring ("Creates a trigger using a work item object.")] HRESULT CreateTrigger( [out] WORD * piNewTrigger, [out] ITaskTrigger ** ppTrigger); [helpstring ("Deletes a trigger from a work item. ")] HRESULT DeleteTrigger( [in] WORD iTrigger); [helpstring ("Retrieves the number of triggers associated with a work item.")] HRESULT GetTriggerCount( [out] WORD * pwCount); [helpstring ("Retrieves a trigger structure.")] HRESULT GetTrigger( [in] WORD iTrigger, [out] ITaskTrigger ** ppTrigger); [helpstring ("Retrieves a trigger string.")] HRESULT GetTriggerString( [in] WORD iTrigger, [out] LPWSTR * ppwszTrigger); [helpstring ("Retrieves the work item run times for a specified time period.")] HRESULT GetRunTimes( [in] const LPSYSTEMTIME pstBegin, [in] const LPSYSTEMTIME pstEnd, [in, out] WORD * pCount, [out] LPSYSTEMTIME * rgstTaskTimes); [helpstring ("Retrieves the next time the work item will run.")] HRESULT GetNextRunTime( [in, out] SYSTEMTIME * pstNextRun); [helpstring ("Sets the idle wait time for the work item.")] HRESULT SetIdleWait( [in] WORD wIdleMinutes, [in] WORD wDeadlineMinutes); [helpstring ("Retrieves the idle wait time for the work item.")] HRESULT GetIdleWait( [out] WORD * pwIdleMinutes, [out] WORD * pwDeadlineMinutes); // Other methods: [helpstring ("Runs the work item.")] HRESULT Run( void); [helpstring ("Ends the execution of the work item.")] HRESULT Terminate( void); [helpstring ("Opens the configuration properties for the work item.")] HRESULT EditWorkItem( [in] HWND hParent, [in] DWORD dwReserved); [helpstring ("Retrieves the most recent time the work item began running.")] HRESULT GetMostRecentRunTime( [out] SYSTEMTIME * pstLastRun); [helpstring ("Retrieves the status of the work item.")] HRESULT GetStatus( [out] HRESULT * phrStatus); [helpstring ("Retrieves the work item's last exit code.")] HRESULT GetExitCode( [out] DWORD * pdwExitCode); // Properties: [helpstring ("Sets the comment for the work item.")] HRESULT SetComment( [in] LPCWSTR pwszComment); [helpstring ("Retrieves the comment for the work item.")] HRESULT GetComment( [out] LPWSTR * ppwszComment); [helpstring ("Sets the creator of the work item.")] HRESULT SetCreator( [in] LPCWSTR pwszCreator); [helpstring ("Retrieves the creator of the work item.")] HRESULT GetCreator( [out] LPWSTR * ppwszCreator); [helpstring ("Stores application-defined data associated with the work item.")] HRESULT SetWorkItemData( [in] WORD cbData, [in] BYTE rgbData[]); [helpstring ("Retrieves application-defined data associated with the work item.")] HRESULT GetWorkItemData( [out] WORD * pcbData, [out] BYTE ** prgbData); [helpstring ("Not currently implemented.")] HRESULT SetErrorRetryCount( [in] WORD wRetryCount); [helpstring ("Not currently implemented.")] HRESULT GetErrorRetryCount( [out] WORD * pwRetryCount); [helpstring ("Not currently implemented.")] HRESULT SetErrorRetryInterval( [in] WORD wRetryInterval); [helpstring ("Not currently implemented.")] HRESULT GetErrorRetryInterval( [out] WORD * pwRetryInterval); [helpstring ("Sets the flags that modify the behavior of the work item.")] HRESULT SetFlags( [in] DWORD dwFlags); [helpstring ("Retrieves the flags that modify the behavior of the work item.")] HRESULT GetFlags( [out] DWORD * pdwFlags); [helpstring ("Sets the account name and password for the work item.")] HRESULT SetAccountInformation( [in] LPCWSTR pwszAccountName, [in] LPCWSTR pwszPassword); [helpstring ("Retrieves the account name for the work item.")] HRESULT GetAccountInformation( [out] LPWSTR * ppwszAccountName); } [ local, object, uuid(148BD524-A2AB-11CE-B11F-00AA00530503), helpstring("Task object interface. The primary means of task object manipulation."), pointer_default(unique) ] interface ITask : IScheduledWorkItem { // Properties that correspond to parameters of CreateProcess: [helpstring ("Assigns a specific application to the current task.")] HRESULT SetApplicationName( [in] LPCWSTR pwszApplicationName); [helpstring ("Retrieves the name of the application that the task is associated with.")] HRESULT GetApplicationName( [out] LPWSTR * ppwszApplicationName); [helpstring ("Sets the command-line parameters for the task.")] HRESULT SetParameters( [in] LPCWSTR pwszParameters); [helpstring ("Retrieves the command-line parameters of a task.")] HRESULT GetParameters( [out] LPWSTR * ppwszParameters); [helpstring ("Sets the working directory for the task.")] HRESULT SetWorkingDirectory( [in] LPCWSTR pwszWorkingDirectory); [helpstring ("Retrieves the working directory of the task.")] HRESULT GetWorkingDirectory( [out] LPWSTR * ppwszWorkingDirectory); [helpstring ("Sets the priority for the task.")] HRESULT SetPriority( [in] DWORD dwPriority); [helpstring ("Retrieves the priority for the task.")] HRESULT GetPriority( [out] DWORD * pdwPriority); // Other properties: [helpstring ("Sets the flags that modify the behavior of the task.")] HRESULT SetTaskFlags( [in] DWORD dwFlags); [helpstring ("Returns the flags used to modify the behavior of the task.")] HRESULT GetTaskFlags( [out] DWORD * pdwFlags); [helpstring ("Sets the maximum length of time the task can run.")] HRESULT SetMaxRunTime( [in] DWORD dwMaxRunTimeMS); [helpstring ("Retrieves the maximum length of time the task can run.")] HRESULT GetMaxRunTime( [out] DWORD * pdwMaxRunTimeMS); } [ local, object, uuid(148BD528-A2AB-11CE-B11F-00AA00530503), helpstring("Work item object enumerator. Enumerates the work item objects within the Tasks folder."), pointer_default(unique) ] interface IEnumWorkItems : IUnknown { // Methods: [helpstring ("Retrieves the next set of tasks in the enumeration sequence.")] HRESULT Next( [in] ULONG celt, [out] LPWSTR ** rgpwszNames, [out] ULONG * pceltFetched); [helpstring ("Skips the next set of tasks in the enumeration sequence.")] HRESULT Skip( [in] ULONG celt); [helpstring ("Resets the enumeration sequence to the beginning. ")] HRESULT Reset( void); [helpstring ("Creates a new enumeration object in the same state as the current enumeration object: the new object points to the same place in the enumeration sequence.")] HRESULT Clone( [out] IEnumWorkItems ** ppEnumWorkItems); } [ local, object, uuid(148BD527-A2AB-11CE-B11F-00AA00530503), helpstring("Task Scheduler interface. Provides location transparent manipulation of task and/or queue objects within the Tasks folder."), pointer_default(unique) ] interface ITaskScheduler : IUnknown { // Methods: [helpstring ("Selects the computer that the ITaskScheduler interface operates on.")] HRESULT SetTargetComputer( [in] LPCWSTR pwszComputer); [helpstring ("Returns the name of the computer on which ITaskScheduler is currently targeted.")] HRESULT GetTargetComputer( [out] LPWSTR * ppwszComputer); [helpstring ("Retrieves a pointer to an OLE enumerator object that enumerates the tasks in the current task folder.")] HRESULT Enum( [out] IEnumWorkItems ** ppEnumWorkItems); [helpstring ("Returns an active interface to the specified task.")] HRESULT Activate( [in] LPCWSTR pwszName, [in] REFIID riid, [out] IUnknown ** ppUnk); [helpstring ("Deletes a task.")] HRESULT Delete( [in] LPCWSTR pwszName); [helpstring ("Allocates space for a new task and retrieves its address.")] HRESULT NewWorkItem( [in] LPCWSTR pwszTaskName, [in] REFCLSID rclsid, [in] REFIID riid, [out] IUnknown ** ppUnk); [helpstring ("Adds a task to the schedule of tasks.")] HRESULT AddWorkItem( [in] LPCWSTR pwszTaskName, [in] IScheduledWorkItem * pWorkItem); [helpstring ("Checks the object type.")] HRESULT IsOfType( [in] LPCWSTR pwszName, [in] REFIID riid); } // // NOTE: Definition of HPROPSHEETPAGE is from sdk\inc\prsht.h // Including this header file causes numerous redefinition errors. // typedef void * HPROPSHEETPAGE; [helpstring ("Used to specify the task page to be retrieved.")] typedef enum _TASKPAGE { TASKPAGE_TASK = 0, TASKPAGE_SCHEDULE = 1, TASKPAGE_SETTINGS = 2 } TASKPAGE; [ local, object, uuid(4086658a-cbbb-11cf-b604-00c04fd8d565), helpstring("Task property page retrieval interface. With this interface, it is possible to retrieve one or more property pages associated with a task object. Task objects inherit this interface."), pointer_default(unique) ] interface IProvideTaskPage : IUnknown { // Methods: [helpstring ("Retrieves the property sheet pages associated with a task.")] HRESULT GetPage( [in] TASKPAGE tpType, [in] BOOL fPersistChanges, [out] HPROPSHEETPAGE * phPage); }; [ uuid(52258859-2318-4860-9C9D-BE05806016AF), helpstring ("Task Scheduler."), version (1.0) ] library MS_TaskSched_lib { importlib ("stdole32.tlb"); [ uuid(148BD520-A2AB-11CE-B11F-00AA00530503), noncreatable, helpstring ("Task.") ] coclass CTask { [default] interface ITask; interface IProvideTaskPage; interface IPersistFile; }; [ uuid(148BD52A-A2AB-11CE-B11F-00AA00530503), helpstring ("Task Scheduler service.") ] coclass CTaskScheduler { [default] interface ITaskScheduler; }; };