ITaskService::Connect method (taskschd.h)
Connects to a remote computer and associates all subsequent calls on this interface with a remote session. If the serverName parameter is empty, then this method will execute on the local computer. If the user is not specified, then the current token is used.
Syntax
HRESULT Connect(
[in, optional] VARIANT serverName,
[in, optional] VARIANT user,
[in, optional] VARIANT domain,
[in, optional] VARIANT password
);
Parameters
[in, optional] serverName
The name of the computer that you want to connect to. If the serverName parameter is empty, then this method will execute on the local computer.
[in, optional] user
The user name that is used during the connection to the computer. If the user is not specified, then the current token is used.
[in, optional] domain
The domain of the user specified in the user parameter.
[in, optional] password
The password that is used to connect to the computer. If the user name and password are not specified, then the current token is used.
Return value
This method can return one of these values.
Return code/value | Description |
---|---|
|
The operation completed successfully. |
|
Access is denied to connect to the Task Scheduler service. |
|
The Task Scheduler service is not running. |
|
The application does not have enough memory to complete the operation or the user, password, or domain has at least one null and one non-null value. |
|
This error is returned in the following situations:
|
|
The user, password, or domain parameters cannot be specified when connecting to a remote Windows XP or Windows Server 2003 computer from a Windows Vista computer. |
Remarks
The ITaskService::Connect method should be called before calling any of the other ITaskService methods.
If you are to connecting to a remote Windows Vista computer from a Windows Vista, you need to allow the Remote Scheduled Tasks Management firewall exception on the remote computer. To allow this exception click Start, Control Panel, Security, Allow a program through Windows Firewall, and then select the Remote Scheduled Tasks Management check box. Then click the Ok button in the Windows Firewall Settings dialog box.
If you are connecting to a remote Windows XP or Windows Server 2003 computer from a Windows Vista computer, you need to allow the File and Printer Sharing firewall exception on the remote computer. To allow this exception click Start, Control Panel, double-click Windows Firewall, select the Exceptions tab, and then select the File and Printer Sharing firewall exception. Then click the OK button in the Windows Firewall dialog box. The Remote Registry service must also be running on the remote computer.
Requirements
Requirement | Value |
---|---|
Minimum supported client | Windows Vista [desktop apps only] |
Minimum supported server | Windows Server 2008 [desktop apps only] |
Target Platform | Windows |
Header | taskschd.h |
Library | Taskschd.lib |
DLL | Taskschd.dll |