{"record":{"id":"689db0b0ec546763","repo":"peass-ng/PEASS-ng","slug":"task-names-may-not-include-any-characters-which-ar","errorCode":null,"errorMessage":"Task names may not include any characters which are invalid for file names.","messagePattern":"Task names may not include any characters which are invalid for file names\\.","errorType":"exception","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"winPEAS/winPEASexe/winPEAS/TaskScheduler/TaskFolder.cs","lineNumber":519,"sourceCode":"\t\t\t\t{\n\t\t\t\t\tthrow new ArgumentException(\"A password must be supplied when specifying TaskLogonType.Password or TaskLogonType.InteractiveTokenOrPassword or TaskLogonType.S4U from another account.\", nameof(password));\n\t\t\t\t}*/\n                else if (logonType == TaskLogonType.Group && password != null)\n                {\n                    throw new ArgumentException(@\"A password cannot be supplied when specifying TaskLogonType.Group.\", nameof(password));\n                }\n                // The following line compensates for an omission in the native library that never actually sets the registration date (thanks ixm7).\n                if (definition.RegistrationInfo.Date == DateTime.MinValue) definition.RegistrationInfo.Date = DateTime.Now;\n                var iRegTask = v2Folder.RegisterTaskDefinition(path, definition.v2Def, (int)createType, userId ?? user.Name, password, logonType, sddl);\n                if (createType == TaskCreation.ValidateOnly && iRegTask == null)\n                    return null;\n                return Task.CreateTask(TaskService, iRegTask);\n            }\n\n            // Check for V1 invalid task names\n            string invChars = Regex.Escape(new string(System.IO.Path.GetInvalidFileNameChars()));\n            if (Regex.IsMatch(path, @\"[\" + invChars + @\"]\"))\n                throw new ArgumentOutOfRangeException(nameof(path), @\"Task names may not include any characters which are invalid for file names.\");\n            if (Regex.IsMatch(path, @\"\\.[^\" + invChars + @\"]{0,3}\\z\"))\n                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.\");\n\n            // Adds ability to set a password for a V1 task. Provided by Arcao.\n            TaskFlags flags = definition.v1Task.GetFlags();\n            if (logonType == TaskLogonType.InteractiveTokenOrPassword && string.IsNullOrEmpty(password))\n                logonType = TaskLogonType.InteractiveToken;\n            switch (logonType)\n            {\n                case TaskLogonType.Group:\n                case TaskLogonType.S4U:\n                case TaskLogonType.None:\n                    throw new NotV1SupportedException(\"This LogonType is not supported on Task Scheduler 1.0.\");\n                case TaskLogonType.InteractiveToken:\n                    flags |= (TaskFlags.RunOnlyIfLoggedOn | TaskFlags.Interactive);\n                    definition.v1Task.SetAccountInformation(user.Name, IntPtr.Zero);\n                    break;\n                case TaskLogonType.ServiceAccount:","sourceCodeStart":501,"sourceCodeEnd":537,"githubUrl":"https://github.com/peass-ng/PEASS-ng/blob/53fb989abc2219826385683a6fee826bd6cd38d6/winPEAS/winPEASexe/winPEAS/TaskScheduler/TaskFolder.cs#L501-L537","documentation":"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.","triggerScenarios":"Thrown at winPEAS/winPEASexe/winPEAS/TaskScheduler/TaskFolder.cs:519 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"53fb989abc2219826385683a6fee826bd6cd38d6","analyzedAt":"2026-09-02T04:25:09.259Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T11:17:12.671Z"}