peass-ng/PEASS-ng · error · ArgumentException

Trigger.Repetition.Interval must be less than Trigger.Repeti

Error message

Trigger.Repetition.Interval must be less than Trigger.Repetition.Duration under Task Scheduler 1.0.

What it means

SetV1TriggerData throws ArgumentException when converting a trigger to Task Scheduler 1.0 format if the repetition Interval (MinutesInterval) is not less than the repetition Duration (MinutesDuration) — and Interval is non-zero. The v1 TASK_TRIGGER structure enforces this constraint, so the library rejects the mapping.

Source

Thrown at winPEAS/winPEASexe/winPEAS/TaskScheduler/Trigger.cs:2405

                    var o = unboundValues[key];
                    CheckBindValue(key, ref o);
                    v2Trigger.GetType().InvokeMember(key, System.Reflection.BindingFlags.SetProperty, null, v2Trigger, new[] { o });
                }
                catch (System.Reflection.TargetInvocationException tie) when (tie.InnerException != null) { throw tie.InnerException; }
                catch { /* ignored */ }
            }
            unboundValues.Clear();
            unboundValues = null;

            repititionPattern = new RepetitionPattern(this);
            repititionPattern.Bind();
        }

        /// <summary>Assigns the unbound TriggerData structure to the V1 trigger instance.</summary>
        internal void SetV1TriggerData()
        {
            if (v1TriggerData.MinutesInterval != 0 && v1TriggerData.MinutesInterval >= v1TriggerData.MinutesDuration)
                throw new ArgumentException("Trigger.Repetition.Interval must be less than Trigger.Repetition.Duration under Task Scheduler 1.0.");
            if (v1TriggerData.EndDate <= v1TriggerData.BeginDate)
                throw new ArgumentException(Resources.Error_TriggerEndBeforeStart);
            if (v1TriggerData.BeginDate == DateTime.MinValue)
                v1TriggerData.BeginDate = DateTime.Now;
            v1Trigger?.SetTrigger(ref v1TriggerData);
            System.Diagnostics.Debug.WriteLine(v1TriggerData);
        }

        /// <summary>Checks the bind value for any conversion.</summary>
        /// <param name="key">The key (property) name.</param>
        /// <param name="o">The value.</param>
        protected virtual void CheckBindValue(string key, ref object o)
        {
            if (o is TimeSpan ts)
                o = Task.TimeSpanToString(ts);
            if (o is DateTime dt)
            {
                if (key == "EndBoundary" && dt == DateTime.MaxValue || key == "StartBoundary" && dt == DateTime.MinValue)

View on GitHub (pinned to 53fb989abc)

Solutions

  1. Set Repetition.Duration greater than Repetition.Interval
  2. Remove Repetition.Interval (set to zero) for v1 compatibility
  3. Target Task Scheduler 2.0 so the v1 constraint doesn't apply

Example fix

// before
trigger.Repetition.Interval = TimeSpan.FromHours(1);
trigger.Repetition.Duration = TimeSpan.FromMinutes(30);
// after
trigger.Repetition.Interval = TimeSpan.FromMinutes(30);
trigger.Repetition.Duration = TimeSpan.FromHours(1);
Defensive patterns

Strategy: validation

Validate before calling

static void ValidateRepetition(Trigger t) {
    var i = t.Repetition.Interval; var d = t.Repetition.Duration;
    if (i != TimeSpan.Zero && d != TimeSpan.Zero && i >= d)
        throw new ArgumentException("Repetition.Interval must be less than Repetition.Duration.");
}

Try / catch

try { folder.RegisterTaskDefinition(name, def, ...); }
catch (ArgumentException ex) when (ex.Message.Contains("Repetition")) { /* adjust interval/duration and retry */ }

Prevention

When it happens

Trigger: Assigning a Trigger whose Repetition.Interval >= Repetition.Duration (or Duration unset/zero while Interval set) then binding it to a v1 task; e.g. Interval = 1 hour, Duration = 30 minutes.

Common situations: Config authored for Task Scheduler 2.0 semantics (where interval may exceed duration meaning indefinite repetition) run on XP/2003; copied XML with repetition values the v1 engine can't express.

Related errors


AI-assisted analysis of peass-ng/PEASS-ng@53fb989abc (2026-09-02). Data as JSON: /api/errors/731b9cbb612bdcdb. Report an issue: GitHub.