 | TaskFolderRegisterTaskDefinition(String, TaskDefinition) Method |
Registers (creates) a task in a specified location using a
TaskDefinition instance to define a task.
Namespace: Microsoft.Win32.TaskSchedulerAssembly: Microsoft.Win32.TaskScheduler (in Microsoft.Win32.TaskScheduler.dll) Version: 2.12.0
Syntaxpublic Task RegisterTaskDefinition(
string path,
TaskDefinition definition
)
Request Example
View SourceParameters
- path String
- 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.
- definition TaskDefinition
- The TaskDefinition of the registered task.
Return Value
TaskA
Task instance that represents the new task.
Example
TaskDefinition td = TaskService.Instance.NewTask();
td.RegistrationInfo.Description = "Does something";
td.Triggers.Add(new WeeklyTrigger(DaysOfTheWeek.Monday | DaysOfTheWeek.Saturday, 2));
td.Actions.Add("notepad.exe", "c:\\test.log");
TaskService.Instance.RootFolder.RegisterTaskDefinition("Test", td);
See Also