The
SetTargetComputer method selects the computer that the
ITaskScheduler interface operates on, allowing remote task management and enumeration.
Syntax
HRESULT SetTargetComputer(
[in] LPCWSTR pwszComputer
);
Parameters
- pwszComputer [in]
-
A pointer to a null-terminated wide character string that specifies the target computer name for the current instance of the
ITaskScheduler interface. Specify the target computer name in the Universal Naming Convention (UNC) format. To indicate the local computer, set this value to NULL or to the local computer's UNC name.
Note When specifying a remote computer name, use two back-slash characters before the computer name. For example, use "\\ComputerName" instead of "ComputerName".
Return Value
The
SetTargetComputer method returns one of the following values.
| Return code | Description |
|
S_OK
| The method was successful.
|
|
SCHED_E_SERVICE_NOT_INSTALLED
| The Task Scheduler service is not installed on the target computer.
|
|
E_ACCESS_DENIED
| The user does not have access to the remote computer.
|
|
E_INVALIDARG
| The pwszComputer parameter is not valid.
|
|
E_OUTOFMEMORY
| A memory allocation failure occurred.
|
Remarks
For a Windows Server 2003, Windows XP, or Windows 2000 computer to create, monitor, or control tasks on a Windows Vista computer, the following operations should be completed on the Windows Vista computer, and the user who is calling the ITaskScheduler::SetTargetComputer method must be a member of the Administrators group on the remote Windows Vista computer.
Enable the "Share File and Printers" exception in Windows Firewall
- Click Start, and then click Control Panel.
- In Control Panel, click Classic View and then double-click the Windows Firewall icon.
- In the Windows Firewall window, click the Exceptions tab and select File and Printer Sharing exception check box.
Enable the "Remote Registry" service
Requirements
| Minimum supported client | Windows 2000 Professional |
| Minimum supported server | Windows 2000 Server |
| Redistributable | Internet Explorer 4.0 or later on Windows NT 4.0 and Windows 95 |
| Header | Mstask.h |
| Library | Mstask.lib |
| DLL | Mstask.dll |
See Also
ITaskScheduler
Send comments about this topic to Microsoft
Build date: 10/29/2008