TaskServiceAddAutomaticMaintenanceTask Method

Adds or updates an Automatic Maintenance Task on the connected machine.

Definition

Namespace: Microsoft.Win32.TaskScheduler
Assembly: Microsoft.Win32.TaskScheduler (in Microsoft.Win32.TaskScheduler.dll) Version: 2.11.1
public Task AddAutomaticMaintenanceTask(
	string taskPathAndName,
	TimeSpan period,
	TimeSpan deadline,
	string executablePath,
	string arguments = null,
	string workingDirectory = null
)

Parameters

taskPathAndName  String
Name of the task with full path.
period  TimeSpan
The amount of time the task needs once executed during regular Automatic maintenance.
deadline  TimeSpan
The amount of time after which the Task Scheduler attempts to run the task during emergency Automatic maintenance, if the task failed to complete during regular Automatic Maintenance.
executablePath  String
The path to an executable file.
arguments  String  (Optional)
The arguments associated with the command-line operation.
workingDirectory  String  (Optional)
The directory that contains either the executable file or the files that are used by the executable file.

Return Value

Task
A Task instance of the Automatic Maintenance Task.

Exceptions

InvalidOperationException Automatic Maintenance tasks are only supported on Windows 8/Server 2012 and later.

See Also