
HRESULT SetCreator(
LPCWSTR pwszCreator
);
Sets the work item's creator.
| S_OK | The operation was successful. |
| E_INVALIDARG | The arguments are not valid. |
| E_OUTOFMEMORY | Not enough memory is available. |
See also IScheduledWorkItem::GetCreator
HRESULT SetErrorRetryCount(
WORD wRetryCount
);
Not currently implemented. Sets the number of times the task will try to run again if an error occurs.
| S_OK | The operation was successful. |
| E_INVALIDARG | The arguments are not valid. |
| E_OUTOFMEMORY | Not enough memory is available. |
| E_NOTIMPL | Not implemented. |
See also IScheduledWorkItem::GetErrorRetryCount
HRESULT SetErrorRetryInterval(
WORD wRetryInterval
);
Not currently implemented. Sets the time interval, in minutes, between task retries after an error occurs.
| S_OK | The operation was successful. |
| E_INVALIDARG | The arguments are not valid. |
| E_OUTOFMEMORY | Not enough memory is available. |
| E_NOTIMPL | Not implemented. |
See also IScheduledWorkItem::GetErrorRetryInterval
HRESULT SetFlags(
DWORD dwFlags
);
Sets the flags that modify the task's behavior.
| S_OK | The operation was successful. |
| E_INVALIDARG | The arguments are not valid. |
| E_OUTOFMEMORY | Not enough memory is available. |
For such converted jobs, the interactive flag is set if the task is intended to be displayed to the user. When this flag is not set, no task items are displayed in the Tasks folder, and no user interface associated with the task is presented to the user when the task is executed.
See also IScheduledWorkItem::GetFlags
HRESULT SetIdleWait(
WORD wIdleMinutes,
WORD wDeadlineMinutes
);
Sets the idle wait time for the task.
If the task has the TASK_EVENT_TRIGGER_ON_IDLE trigger, the task runs when wIdleMinutes have elapsed since the most recent keyboard or mouse event.
If the TASK_FLAG_START_ONLY_IF_IDLE flag is set, the task runs only after a period of wIdleMinutes elapses with no mouse or keyboard activity. The Task Scheduler service will wait up to wDeadlineMinutes past the scheduled start time of the task for the required wIdleMinutes of idle time to elapse.
See also IScheduledWorkItem::GetIdleWait, Idle Triggers
HRESULT SetWorkItemData(
WORD cBytes,
BYTE rgbData[]
);
Stores application-defined data associated with the work item.
| S_OK | The operation was successful. |
| E_INVALIDARG | The arguments are not valid. |
| E_OUTOFMEMORY | Not enough memory is available. |
See also IScheduledWorkItem::GetWorkItemData
HRESULT Terminate(void);
Ends the execution of the work item.
| S_OK | The operation was successful. |
| E_INVALIDARG | The arguments are not valid. |
| E_OUTOFMEMORY | Not enough memory is available. |
Applications use the methods of the ITaskScheduler interface to schedule tasks. The following list of methods is organized in vtable order.
| ITaskScheduler methods |
| SetTargetComputer |
| GetTargetComputer |
| Enum |
| Activate |
| Delete |
| NewWorkItem |
| AddWorkItem |
| IsOfType |
HRESULT Activate(
LPCWSTR pwszName,
REFIID riid,
IUnknown ** ppunk
);
Returns an active interface to the specified task.
| S_OK | The method was successful. |
| SCHED_E_UNKNOWN_OBJECT_VERSION | The task object version is either unsupported or invalid. |
| E_INVALIDARG | pwszName is not valid. |
| E_OUTOFMEMORY | A memory allocation failure occurred. |
HRESULT AddWorkItem(
LPCWSTR pwszTaskName,
IScheduledWorkItem * pWorkItem
);
Adds a task to the schedule of tasks. Unlike NewWorkItem, this method requires that you first create an object that supports the IScheduledWorkItem interface and pass its address in the pWorkItem parameter.
| S_OK | The operation was successful. |
| ERROR_FILE_EXISTS | A task with the specified name already exists. |
| E_INVALIDARG | One or more of the arguments are not valid. |
| E_OUTOFMEMORY | Not enough memory is available to complete the operation. |
See also ITaskScheduler::NewWorkItem
HRESULT Delete(
LPCWSTR pwszName
);
Deletes a task.
| S_OK | The operation was successful. |
| E_INVALIDARG | The arguments are not valid. |
| E_OUTOFMEMORY | Not enough memory is available. |
HRESULT Enum(
IEnumTasks ** ppEnumTasks
);
Retrieves a pointer to an OLE enumerator object that enumerates the tasks in the current task folder.
| S_OK | The operation was successful. |
| E_INVALIDARG | The arguments are not valid. |
| E_OUTOFMEMORY | Not enough memory is available. |
The current folder resides on the computer returned by GetTargetComputer, which defaults to the local computer if not previously set by a call to SetTargetComputer.
HRESULT GetTargetComputer(
LPWSTR * ppwszComputer
);
Returns the computer name on which ITaskScheduler is currently targeted.
| S_OK | The operation was successful. |
| E_INVALIDARG | The arguments are not valid. |
| E_OUTOFMEMORY | Not enough memory is available. |
HRESULT IsOfType(
LPCWSTR pwszName,
REFIID riid
);
Checks the object's type to verify that it supports a particular interface.
HRESULT NewWorkItem(
LPCWSTR pwszTaskName,
REFCLSID rclsid,
REFIID riid,
IUnknown ** ppunk
);
Allocates space for a new task and retrieves its address. Unlike AddWorkItem, this function handles memory allocation automatically.
| S_OK | The operation was successful. |
| ERROR_FILE_EXISTS | A task with the specified name already exists. |
| E_INVALIDARG | One or more of the arguments are not valid. |
| E_OUTOFMEMORY | Not enough memory is available to complete the operation. |
See also ITaskScheduler::AddWorkItem
HRESULT SetTargetComputer(
LPCWSTR pwszComputer
);
Selects the computer that the ITaskScheduler interface operates on. This allows remote task management and enumeration. The user must have administrative access on the remote computer to use this method. For more information on remote installation requirements, refer to Mstask.hlp.
| S_OK | The method was successful. |
| SCHED_E_SERVICE_NOT_INSTALLED | The Task Scheduler service is not installed on the target computer. |
| E_INVALIDARG | pwszComputer is not valid. |
| E_OUTOFMEMORY | A memory allocation failure occurred. |
Applications use the methods of the ITask interface to set and retrieve task information and to run and terminate tasks. The following list of methods is organized in vtable order.
| ITask methods |
| SetApplicationName |
| GetApplicationName |
| SetParameters |
| GetParameters |
| SetWorkingDirectory |
| GetWorkingDirectory |
| SetPriority |
| GetPriority |
| SetTaskFlags |
| GetTaskFlags |
| SetMaxRunTime |
| GetMaxRunTime |
HRESULT GetApplicationName(
LPWSTR * ppwszApplicationName
);
Retrieves the name of the application that the task is associated with.
| S_OK | The operation was successful. |
| E_INVALIDARG | The arguments are not valid. |
| E_OUTOFMEMORY | Not enough memory is available. |
If you set the application name property to an executable file, you can set the parameters property to the command-line arguments to pass to that executablefor example, ApplicationName=notepad.exe and Parameters=foo.txt.
However, if you set the ApplicationName property to a non-executable file, the parameters property will be ignored, because the application name in this case is the parameterfor example, ApplicationName=foo.txt.
See also ITask::SetApplicationName
HRESULT GetMaxRunTime(
DWORD * pdwMaxRunTime
);
Retrieves the maximum time, in milliseconds, the task can run before terminating.
| S_OK | The operation was successful. |
| E_INVALIDARG | The arguments are not valid. |
| E_OUTOFMEMORY | Not enough memory is available. |
If the maximum run time is reached during the execution of a task, the Scheduling Agent first sends a WM_CLOSE message to the associated application. If the application hasn't exited within three minutes, TerminateProcess is run.
See also ITask::SetMaxRunTime
HRESULT GetParameters(
LPWSTR * ppwszParameters
);
Retrieves the task's command-line parameters.
| S_OK | The operation was successful. |
| E_INVALIDARG | The arguments are not valid. |
| E_OUTOFMEMORY | Not enough memory is available. |
See also ITask::SetParameters
HRESULT GetPriority(
DWORD * pdwPriority
);
Retrieves the priority for the task.
| S_OK | The operation was successful. |
| E_INVALIDARG | The arguments are not valid. |
| E_OUTOFMEMORY | Not enough memory is available. |
| REALTIME_PRIORITY_CLASS |
| HIGH_PRIORITY_CLASS |
| NORMAL_PRIORITY_CLASS |
| IDLE_PRIORITY_CLASS |
See also ITask::SetPriority
HRESULT GetTaskFlags(
DWORD * pdwFlags
);
Returns the flags that modify the task's behavior.
| S_OK | The operation was successful. |
| E_INVALIDARG | The arguments are not valid. |
| E_OUTOFMEMORY | Not enough memory is available. |
HRESULT GetWorkingDirectory(
LPWSTR * ppwszWorkingDirectory
);
Retrieves the task's working directory.
| S_OK | The operation was successful. |
| E_INVALIDARG | The arguments are not valid. |
| E_OUTOFMEMORY | Not enough memory is available. |
See also ITask::SetWorkingDirectory
HRESULT SetApplicationName(
LPCWSTR pwszApplicationName
);
Assigns a specific application to the current task.
| S_OK | The operation was successful. |
| E_INVALIDARG | The arguments are not valid. |
| E_OUTOFMEMORY | Not enough memory is available. |
If you do not specify a path for the application, the Task Scheduler searches the environment path to find the correct path. If the application name specifies a program, it should use the .exe extension to ensure that the Scheduling Agent user interface properly displays the application's icon.
See also ITask::GetApplicationName
HRESULT SetMaxRunTime(
DWORD dwMaxRunTime
);
Sets the maximum time the task can run before terminating.
| S_OK | The operation was successful. |
| E_INVALIDARG | The arguments are not valid. |
| E_OUTOFMEMORY | Not enough memory is available. |
If the maximum run time is reached during the execution of a task, the Scheduling Agent first sends a WM_CLOSE message to the associated application. If the application has not exited within three minutes, TerminateProcess is run.
See also ITask::GetMaxRunTime
HRESULT SetParameters(
LPCWSTR pwszParameters
);
Sets the command-line parameters for the task.
| S_OK | The operation was successful. |
| E_INVALIDARG | The arguments are not valid. |
| E_OUTOFMEMORY | Not enough memory is available. |
If the Application Name method contains a document to run by association, the Parameters methods are ignored. To clear the command-line parameter property, set pwszParameters to L"".
The application name and parameters properties are accessed through the Application Name Set and Get methods on the ITask interface. They are properties of a task object.
See also ITask::GetParameters
HRESULT SetPriority(
DWORD dwPriority
);
Sets the priority for the task.
| REALTIME_PRIORITY_CLASS |
| HIGH_PRIORITY_CLASS |
| NORMAL_PRIORITY_CLASS |
| IDLE_PRIORITY_CLASS |
See also ITask::GetPriority
HRESULT SetTaskFlags(
DWORD dwFlags
);
Sets the flags that modify the task's behavior.
| S_OK | The operation was successful. |
| E_INVALIDARG | The arguments are not valid. |
| E_OUTOFMEMORY | Not enough memory is available. |
For such converted jobs, the interactive flag is set if the task is intended to be displayed to the user. When this flag is not set, no task items are displayed in the Tasks folder, and no user interface associated with the task is presented to the user when the task is executed.
See also ITask::GetTaskFlags
© 1997 Microsoft Corporation. All rights reserved. Terms of Use.