peass-ng/PEASS-ng · error · ArgumentOutOfRangeException
Task names may not include any characters which are invalid
Error message
Task names may not include any characters which are invalid for file names.
What it means
Path-validation guard in RegisterTaskDefinition for Task Scheduler 1.0: the task path is tested against the set of characters invalid in file names (via Path.GetInvalidFileNameChars) because V1 stores each task as a .job file whose name is the task path. Any invalid filename character (e.g. \<>:*?"| or control chars) in path triggers this ArgumentOutOfRangeException.
Source
Thrown at winPEAS/winPEASexe/winPEAS/TaskScheduler/TaskFolder.cs:519
{
throw new ArgumentException("A password must be supplied when specifying TaskLogonType.Password or TaskLogonType.InteractiveTokenOrPassword or TaskLogonType.S4U from another account.", nameof(password));
}*/
else if (logonType == TaskLogonType.Group && password != null)
{
throw new ArgumentException(@"A password cannot be supplied when specifying TaskLogonType.Group.", nameof(password));
}
// The following line compensates for an omission in the native library that never actually sets the registration date (thanks ixm7).
if (definition.RegistrationInfo.Date == DateTime.MinValue) definition.RegistrationInfo.Date = DateTime.Now;
var iRegTask = v2Folder.RegisterTaskDefinition(path, definition.v2Def, (int)createType, userId ?? user.Name, password, logonType, sddl);
if (createType == TaskCreation.ValidateOnly && iRegTask == null)
return null;
return Task.CreateTask(TaskService, iRegTask);
}
// Check for V1 invalid task names
string invChars = Regex.Escape(new string(System.IO.Path.GetInvalidFileNameChars()));
if (Regex.IsMatch(path, @"[" + invChars + @"]"))
throw new ArgumentOutOfRangeException(nameof(path), @"Task names may not include any characters which are invalid for file names.");
if (Regex.IsMatch(path, @"\.[^" + invChars + @"]{0,3}\z"))
throw new ArgumentOutOfRangeException(nameof(path), @"Task names ending with a period followed by three or fewer characters cannot be retrieved due to a bug in the native library.");
// Adds ability to set a password for a V1 task. Provided by Arcao.
TaskFlags flags = definition.v1Task.GetFlags();
if (logonType == TaskLogonType.InteractiveTokenOrPassword && string.IsNullOrEmpty(password))
logonType = TaskLogonType.InteractiveToken;
switch (logonType)
{
case TaskLogonType.Group:
case TaskLogonType.S4U:
case TaskLogonType.None:
throw new NotV1SupportedException("This LogonType is not supported on Task Scheduler 1.0.");
case TaskLogonType.InteractiveToken:
flags |= (TaskFlags.RunOnlyIfLoggedOn | TaskFlags.Interactive);
definition.v1Task.SetAccountInformation(user.Name, IntPtr.Zero);
break;
case TaskLogonType.ServiceAccount:View on GitHub (pinned to 53fb989abc)
Solutions
- Sanitize the task path by removing or replacing characters returned by System.IO.Path.GetInvalidFileNameChars() before registering
- Use only alphanumerics, dashes and underscores in the task name
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at winPEAS/winPEASexe/winPEAS/TaskScheduler/TaskFolder.cs:519 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of peass-ng/PEASS-ng@53fb989abc (2026-09-02).
Data as JSON: /api/errors/689db0b0ec546763.
Report an issue: GitHub.