 | TaskServiceAddTask Method (String, QuickTriggerType, String, String, String, String, TaskLogonType, String) |
Creates a new task, registers the task, and returns the instance.
Namespace:
Microsoft.Win32.TaskScheduler
Assembly:
Microsoft.Win32.TaskScheduler (in Microsoft.Win32.TaskScheduler.dll) Version: 2.10.1
Syntaxpublic Task AddTask(
string path,
QuickTriggerType trigger,
string exePath,
string arguments = null,
string userId = null,
string password = null,
TaskLogonType logonType = TaskLogonType.InteractiveToken,
string description = null
)
Public Function AddTask (
path As String,
trigger As QuickTriggerType,
exePath As String,
Optional arguments As String = Nothing,
Optional userId As String = Nothing,
Optional password As String = Nothing,
Optional logonType As TaskLogonType = TaskLogonType.InteractiveToken,
Optional description As String = Nothing
) As Task
public:
Task^ AddTask(
String^ path,
QuickTriggerType trigger,
String^ exePath,
String^ arguments = nullptr,
String^ userId = nullptr,
String^ password = nullptr,
TaskLogonType logonType = TaskLogonType::InteractiveToken,
String^ description = nullptr
)
Request Example
View SourceParameters
- path
- Type: SystemString
The task name. If this value is NULL, the task will be registered in the root task folder and the task name will be a GUID value
that is created by the Task Scheduler service. A task name cannot begin or end with a space character. The '.' character cannot
be used to specify the current task folder and the '..' characters cannot be used to specify the parent task folder in the path.
- trigger
- Type: Microsoft.Win32.TaskSchedulerQuickTriggerType
The Trigger to determine when to run the task. - exePath
- Type: SystemString
The executable path. - arguments (Optional)
- Type: SystemString
The arguments (optional). Value can be NULL. - userId (Optional)
- Type: SystemString
The user credentials used to register the task. - password (Optional)
- Type: SystemString
The password for the userId used to register the task. - logonType (Optional)
- Type: Microsoft.Win32.TaskSchedulerTaskLogonType
A TaskLogonType value that defines what logon technique is used to run the registered task.
- description (Optional)
- Type: SystemString
The task description.
Return Value
Type:
TaskA
Task instance of the registered task.
Examples
TaskService.Instance.AddTask("Test", QuickTriggerType.Daily, "notepad.exe", "c:\\test.log"));
See Also