{"record":{"id":"0488fd582db5555e","repo":"peass-ng/PEASS-ng","slug":"notv1supportedexception","errorCode":null,"errorMessage":"NotV1SupportedException","messagePattern":"NotV1SupportedException","errorType":"exception","errorClass":"NotV1SupportedException","httpStatus":null,"severity":"error","filePath":"winPEAS/winPEASexe/winPEAS/TaskScheduler/Task.cs","lineNumber":3377,"sourceCode":"        }\n\n        /// <summary>Gets or sets a value that specifies how long the Task Scheduler will attempt to restart the task.</summary>\n        /// <value>\n        /// A value that specifies how long the Task Scheduler will attempt to restart the task. If this property is set, the <see\n        /// cref=\"RestartCount\"/> property must also be set. The maximum time allowed is 31 days, and the minimum time allowed is 1 minute.\n        /// </value>\n        /// <exception cref=\"NotV1SupportedException\">Not supported under Task Scheduler 1.0.</exception>\n        [DefaultValue(typeof(TimeSpan), \"00:00:00\")]\n        [XmlIgnore]\n        public TimeSpan RestartInterval\n        {\n            get => v2Settings != null ? Task.StringToTimeSpan(v2Settings.RestartInterval) : TimeSpan.Zero;\n            set\n            {\n                if (v2Settings != null)\n                    v2Settings.RestartInterval = Task.TimeSpanToString(value);\n                else\n                    throw new NotV1SupportedException();\n                OnNotifyPropertyChanged();\n            }\n        }\n\n        /// <summary>\n        /// 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.\n        /// </summary>\n        [DefaultValue(false)]\n        public bool RunOnlyIfIdle\n        {\n            get => v2Settings?.RunOnlyIfIdle ?? v1Task.HasFlags(TaskFlags.StartOnlyIfIdle);\n            set\n            {\n                if (v2Settings != null)\n                    v2Settings.RunOnlyIfIdle = value;\n                else\n                    v1Task.SetFlags(TaskFlags.StartOnlyIfIdle, value);\n                OnNotifyPropertyChanged();","sourceCodeStart":3359,"sourceCodeEnd":3395,"githubUrl":"https://github.com/peass-ng/PEASS-ng/blob/53fb989abc2219826385683a6fee826bd6cd38d6/winPEAS/winPEASexe/winPEAS/TaskScheduler/Task.cs#L3359-L3395","documentation":"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.","triggerScenarios":"Setting taskDefinition.Settings.RestartInterval to any TimeSpan when the definition is bound to a Task Scheduler 1.0 service (no v2Settings object).","commonSituations":"Configuring failure-recovery settings on Windows XP/2000 or a TaskService connected to a v1-only store; shared configuration code applying v2 settings unconditionally.","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"],"exampleFix":"// before\nsettings.RestartInterval = TimeSpan.FromMinutes(5);\n// after\nif (svc.HighestSupportedVersion >= TaskServiceVersion.V2)\n    settings.RestartInterval = TimeSpan.FromMinutes(5);","handlingStrategy":"validation","validationCode":"if (svc.HighestSupportedVersion < TaskServiceVersion.V2)\n    Console.WriteLine(\"RestartInterval requires Task Scheduler 2.0; setting skipped\");","typeGuard":"bool CanSetRestartInterval(Microsoft.Win32.TaskScheduler.TaskService svc) => svc.HighestSupportedVersion >= TaskServiceVersion.V2;","tryCatchPattern":"try { settings.RestartInterval = interval; }\ncatch (NotV1SupportedException) { /* implement retry in the task application instead */ }","preventionTips":["Gate v2-only settings behind a HighestSupportedVersion >= V2 check","Avoid unconditionally copying v2 settings templates onto v1 tasks"],"tags":["taskscheduler","notv1supported","restart-interval","legacy-windows"],"backgroundTag":"unsupported-platform-feature","analyzedSha":"53fb989abc2219826385683a6fee826bd6cd38d6","analyzedAt":"2026-09-02T04:25:09.259Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T11:17:12.671Z"}