peass-ng/PEASS-ng · error · NotV1SupportedException
NotV1SupportedException
Error message
NotV1SupportedException
What it means
The TaskDefinition.Settings.RestartInterval property is only available in Task Scheduler 2.0+. On a v1 task (v2Settings is null), the setter throws NotV1SupportedException because Task Scheduler 1.0 cannot restart a failed task automatically.
Source
Thrown at winPEAS/winPEASexe/winPEAS/TaskScheduler/Task.cs:3377
}
/// <summary>Gets or sets a value that specifies how long the Task Scheduler will attempt to restart the task.</summary>
/// <value>
/// A value that specifies how long the Task Scheduler will attempt to restart the task. If this property is set, the <see
/// cref="RestartCount"/> property must also be set. The maximum time allowed is 31 days, and the minimum time allowed is 1 minute.
/// </value>
/// <exception cref="NotV1SupportedException">Not supported under Task Scheduler 1.0.</exception>
[DefaultValue(typeof(TimeSpan), "00:00:00")]
[XmlIgnore]
public TimeSpan RestartInterval
{
get => v2Settings != null ? Task.StringToTimeSpan(v2Settings.RestartInterval) : TimeSpan.Zero;
set
{
if (v2Settings != null)
v2Settings.RestartInterval = Task.TimeSpanToString(value);
else
throw new NotV1SupportedException();
OnNotifyPropertyChanged();
}
}
/// <summary>
/// Gets or sets a Boolean value that indicates that the Task Scheduler will run the task only if the computer is in an idle condition.
/// </summary>
[DefaultValue(false)]
public bool RunOnlyIfIdle
{
get => v2Settings?.RunOnlyIfIdle ?? v1Task.HasFlags(TaskFlags.StartOnlyIfIdle);
set
{
if (v2Settings != null)
v2Settings.RunOnlyIfIdle = value;
else
v1Task.SetFlags(TaskFlags.StartOnlyIfIdle, value);
OnNotifyPropertyChanged();View on GitHub (pinned to 53fb989abc)
Solutions
- Only set RestartInterval when TaskService.HighestSupportedVersion >= V2
- Skip the setting on v1 tasks and rely on the task application's own retry logic
- Guard with a version check or try-catch for NotV1SupportedException
- Move to Task Scheduler 2.0 (Windows Vista+) for restart-on-failure support
Example fix
// before
settings.RestartInterval = TimeSpan.FromMinutes(5);
// after
if (svc.HighestSupportedVersion >= TaskServiceVersion.V2)
settings.RestartInterval = TimeSpan.FromMinutes(5); Defensive patterns
Strategy: validation
Validate before calling
if (svc.HighestSupportedVersion < TaskServiceVersion.V2)
Console.WriteLine("RestartInterval requires Task Scheduler 2.0; setting skipped"); Type guard
bool CanSetRestartInterval(Microsoft.Win32.TaskScheduler.TaskService svc) => svc.HighestSupportedVersion >= TaskServiceVersion.V2;
Try / catch
try { settings.RestartInterval = interval; }
catch (NotV1SupportedException) { /* implement retry in the task application instead */ } Prevention
- Gate v2-only settings behind a HighestSupportedVersion >= V2 check
- Avoid unconditionally copying v2 settings templates onto v1 tasks
When it happens
Trigger: Setting taskDefinition.Settings.RestartInterval to any TimeSpan when the definition is bound to a Task Scheduler 1.0 service (no v2Settings object).
Common situations: Configuring failure-recovery settings on Windows XP/2000 or a TaskService connected to a v1-only store; shared configuration code applying v2 settings unconditionally.
Related errors
- Unsupported priority level on Task Scheduler 1.0.
- NotV1SupportedException
- A maximum of 32 actions is allowed within a single task.
- Attachments array cannot contain more than 8 items.
- Each value of the array must contain a valid file reference.
AI-assisted analysis of peass-ng/PEASS-ng@53fb989abc (2026-09-02).
Data as JSON: /api/errors/0488fd582db5555e.
Report an issue: GitHub.