peass-ng/PEASS-ng · error · ArgumentOutOfRangeException

On systems prior to Windows 10, all individual parameters mu

Error message

On systems prior to Windows 10, all individual parameters must be less than 260 characters.

What it means

Task.Run() validates the parameters array before passing it to the native Task Scheduler COM API. On systems whose highest supported Task Scheduler version is below 1.5 (pre-Windows 10), any individual parameter string of 260 or more characters triggers this ArgumentOutOfRangeException, because the older native API cannot accept such long parameters.

Source

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

        /// </param>
        /// <returns>A <see cref="RunningTask"/> instance that defines the new instance of the task.</returns>
        /// <example>
        /// <code lang="cs">
        ///<![CDATA[
        /// // Run the current task with a parameter
        /// var runningTask = myTaskInstance.Run("info");
        /// Console.Write(string.Format("Running task's current action is {0}.", runningTask.CurrentAction));
        ///]]>
        /// </code>
        /// </example>
        public RunningTask Run(params string[] parameters)
        {
            if (v2Task != null)
            {
                if (parameters.Length > 32)
                    throw new ArgumentOutOfRangeException(nameof(parameters), "A maximum of 32 values is allowed.");
                if (TaskService.HighestSupportedVersion < TaskServiceVersion.V1_5 && parameters.Any(p => (p?.Length ?? 0) >= 260))
                    throw new ArgumentOutOfRangeException(nameof(parameters), "On systems prior to Windows 10, all individual parameters must be less than 260 characters.");
                var irt = v2Task.Run(parameters.Length == 0 ? null : parameters);
                return irt != null ? new RunningTask(TaskService, v2Task, irt) : null;
            }

            v1Task.Run();
            return new RunningTask(TaskService, v1Task);
        }

        /// <summary>Runs the registered task immediately using specified flags and a session identifier.</summary>
        /// <param name="flags">Defines how the task is run.</param>
        /// <param name="sessionID">
        /// <para>The terminal server session in which you want to start the task.</para>
        /// <para>
        /// If the <see cref="TaskRunFlags.UseSessionId"/> value is not passed into the <paramref name="flags"/> parameter, then the value
        /// specified in this parameter is ignored.If the <see cref="TaskRunFlags.UseSessionId"/> value is passed into the flags parameter
        /// and the sessionID value is less than or equal to 0, then an invalid argument error will be returned.
        /// </para>
        /// <para>

View on GitHub (pinned to 53fb989abc)

Solutions

  1. Shorten each parameter string to under 260 characters (e.g. pass a path to a script file instead of inline content)
  2. Detect the OS version at runtime and use a different invocation strategy (e.g. write arguments to a temp file and pass its short path)
  3. Upgrade/target Windows 10+ where Task Scheduler 1.5 supports longer parameters
  4. Ensure no more than 32 parameters are passed (also enforced here)

Example fix

// before
task.Run(longConfigJson);
// after
if (longConfigJson.Length >= 260)
    File.WriteAllText(tempFile, longConfigJson);
task.Run(tempFile);
Defensive patterns

Strategy: validation

Validate before calling

if (TaskService.HighestSupportedVersion < TaskServiceVersion.V1_5)
    foreach (var p in parameters)
        if (p != null && p.Length >= 260) throw new ArgumentException("Parameter exceeds 260 chars on pre-Win10: " + p);

Try / catch

try { task.Run(parameters); }
catch (ArgumentOutOfRangeException ex) { /* shorten params or fallback */ }

Prevention

When it happens

Trigger: Calling task.Run(...) with one or more parameter strings whose length is >= 260 while running on a system where TaskService.HighestSupportedVersion < TaskServiceVersion.V1_5. Also thrown when more than 32 values are supplied.

Common situations: Passing long file paths, long command-line arguments, or encoded blobs as task parameters on Windows 7/8/8.1 or when targeting a down-level remote machine.

Related errors


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