 | TaskServiceAddAutomaticMaintenanceTask Method |
Adds or updates an Automatic Maintenance Task on the connected machine.
Namespace:
Microsoft.Win32.TaskScheduler
Assembly:
Microsoft.Win32.TaskScheduler (in Microsoft.Win32.TaskScheduler.dll) Version: 2.10.1
Syntaxpublic Task AddAutomaticMaintenanceTask(
string taskPathAndName,
TimeSpan period,
TimeSpan deadline,
string executablePath,
string arguments = null,
string workingDirectory = null
)
Public Function AddAutomaticMaintenanceTask (
taskPathAndName As String,
period As TimeSpan,
deadline As TimeSpan,
executablePath As String,
Optional arguments As String = Nothing,
Optional workingDirectory As String = Nothing
) As Task
public:
Task^ AddAutomaticMaintenanceTask(
String^ taskPathAndName,
TimeSpan period,
TimeSpan deadline,
String^ executablePath,
String^ arguments = nullptr,
String^ workingDirectory = nullptr
)
Request Example
View SourceParameters
- taskPathAndName
- Type: SystemString
Name of the task with full path. - period
- Type: SystemTimeSpan
The amount of time the task needs once executed during regular Automatic maintenance. - deadline
- Type: SystemTimeSpan
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
- Type: SystemString
The path to an executable file. - arguments (Optional)
- Type: SystemString
The arguments associated with the command-line operation. - workingDirectory (Optional)
- Type: SystemString
The directory that contains either the executable file or the files that are used by the executable file.
Return Value
Type:
TaskA
Task instance of the Automatic Maintenance Task.
ExceptionsException | Condition |
---|
InvalidOperationException |
Automatic Maintenance tasks are only supported on Windows 8/Server 2012 and later.
|
See Also