peass-ng/PEASS-ng · error · ArgumentOutOfRangeException

On systems prior to Windows 10, no individual parameter may

Error message

On systems prior to Windows 10, no individual parameter may be more than 260 characters.

What it means

RunEx documents that on systems earlier than Windows 10, any single parameter longer than 260 characters (the MAX_PATH-era limit) is rejected. This is a documented platform restriction on parameter length for pre-Win10 task execution, with the over-long parameter string as the at-fault input.

Source

Thrown at winPEAS/winPEASexe/winPEAS/TaskScheduler/Task.cs:1481

        /// <exception cref="NotV1SupportedException">Not supported under Task Scheduler 1.0.</exception>
        /// <example>
        /// <code lang="cs">
        ///<![CDATA[
        /// // Run the current task with a parameter as a different user and ignoring any of the conditions.
        /// var runningTask = myTaskInstance.RunEx(TaskRunFlags.IgnoreConstraints, 0, "DOMAIN\\User", "info");
        /// Console.Write(string.Format("Running task's current action is {0}.", runningTask.CurrentAction));
        ///]]>
        /// </code>
        /// </example>
        public RunningTask RunEx(TaskRunFlags flags, int sessionID, string user, params string[] parameters)
        {
            if (v2Task == null) throw new NotV1SupportedException();
            if (parameters == null || parameters.Any(s => s == null))
                throw new ArgumentNullException(nameof(parameters), "The array and none of the values passed as parameters may be `null`.");
            if (parameters.Length > 32)
                throw new ArgumentOutOfRangeException(nameof(parameters), "A maximum of 32 parameters can be supplied to RunEx.");
            if (TaskService.HighestSupportedVersion < TaskServiceVersion.V1_5 && parameters.Any(p => (p?.Length ?? 0) >= 260))
                throw new ArgumentOutOfRangeException(nameof(parameters), "On systems prior to Windows 10, no individual parameter may be more than 260 characters.");
            var irt = v2Task.RunEx(parameters.Length == 0 ? null : parameters, (int)flags, sessionID, user);
            return irt != null ? new RunningTask(TaskService, v2Task, irt) : null;
        }

        /// <summary>
        /// Applies access control list (ACL) entries described by a <see cref="TaskSecurity"/> object to the file described by the current
        /// <see cref="Task"/> object.
        /// </summary>
        /// <param name="taskSecurity">
        /// A <see cref="TaskSecurity"/> object that describes an access control list (ACL) entry to apply to the current task.
        /// </param>
        /// <example>
        /// <para>Give read access to all authenticated users for a task.</para>
        /// <code lang="cs">
        ///<![CDATA[
        /// // Assume variable 'task' is a valid Task instance
        /// var taskSecurity = task.GetAccessControl();
        /// taskSecurity.AddAccessRule(new TaskAccessRule("Authenticated Users", TaskRights.Read, System.Security.AccessControl.AccessControlType.Allow));

View on GitHub (pinned to 53fb989abc)

Solutions

  1. Keep each parameter under 260 characters
  2. Persist long data to a temp file and pass its (short) path instead
  3. Only call RunEx with long parameters on Windows 10+ (Task Scheduler 1.5+)
  4. Pre-check TaskService.HighestSupportedVersion and branch your logic

Example fix

// before
task.RunEx(flags, 0, user, veryLongArg);
// after
if (Environment.OSVersion.Version >= new Version(10, 0) || veryLongArg.Length < 260)
    task.RunEx(flags, 0, user, veryLongArg);
else
    task.RunEx(flags, 0, user, WriteToTempFile(veryLongArg));
Defensive patterns

Strategy: validation

Validate before calling

if (TaskService.HighestSupportedVersion < TaskServiceVersion.V1_5 &&
    parameters.Any(p => p?.Length >= 260))
    throw new ArgumentException("Parameter >= 260 chars not supported pre-Win10");

Try / catch

try { task.RunEx(flags, sid, user, parameters); }
catch (ArgumentOutOfRangeException) { /* fallback: temp-file strategy */ }

Prevention

When it happens

Trigger: Calling task.RunEx(...) with any parameter string of length >= 260 while TaskService.HighestSupportedVersion < TaskServiceVersion.V1_5.

Common situations: Long file paths or long inline arguments on Windows 7/8 or a down-level remote target; embedding config data as a task parameter.

Related errors


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