{"record":{"id":"4bfb1a081cbfe9ce","repo":"peass-ng/PEASS-ng","slug":"path-not-found","errorCode":null,"errorMessage":"Path not found","messagePattern":"Path not found","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"winPEAS/winPEASexe/winPEAS/TaskScheduler/TaskFolderCollection.cs","lineNumber":67,"sourceCode":"            }\n        }\n\n        /// <summary>Gets the specified folder from the collection.</summary>\n        /// <param name=\"path\">The path of the folder to be retrieved.</param>\n        /// <returns>A TaskFolder instance that represents the requested folder.</returns>\n        public TaskFolder this[[NotNull] string path]\n        {\n            get\n            {\n                try\n                {\n                    if (v2FolderList != null)\n                        return parent.GetFolder(path);\n                    if (v1FolderList != null && v1FolderList.Length > 0 && (path == string.Empty || path == \"\\\\\"))\n                        return v1FolderList[0];\n                }\n                catch { }\n                throw new ArgumentException(@\"Path not found\", nameof(path));\n            }\n        }\n\n        /// <summary>Adds an item to the <see cref=\"ICollection{T}\"/>.</summary>\n        /// <param name=\"item\">The object to add to the <see cref=\"ICollection{T}\"/>.</param>\n        /// <exception cref=\"System.NotImplementedException\">\n        /// This action is technically unfeasible due to limitations of the underlying library. Use the <see\n        /// cref=\"TaskFolder.CreateFolder(string, string, bool)\"/> instead.\n        /// </exception>\n        public void Add([NotNull] TaskFolder item) => throw new NotImplementedException();\n\n        /// <summary>Removes all items from the <see cref=\"ICollection{T}\"/>.</summary>\n        public void Clear()\n        {\n            if (v2FolderList != null)\n            {\n                for (var i = v2FolderList.Count; i > 0; i--)\n                    parent.DeleteFolder(v2FolderList[i].Name, false);","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/peass-ng/PEASS-ng/blob/53fb989abc2219826385683a6fee826bd6cd38d6/winPEAS/winPEASexe/winPEAS/TaskScheduler/TaskFolderCollection.cs#L49-L85","documentation":"The TaskFolderCollection indexer throws ArgumentException('Path not found') when the requested folder path cannot be resolved: the underlying GetFolder call fails on v2, and on v1 the path is not the empty/root path. The library swallows the original COM exception and rethrows this generic ArgumentException naming the 'path' parameter.","triggerScenarios":"Accessing TaskService.GetFolder(path) / folder.SubFolders[path] with a path that does not exist, is misspelled, or uses the wrong separator (must start with '\\'), on a folder whose subfolder lookup fails.","commonSituations":"Enumerating tasks when an expected folder was deleted or renamed; assuming '\\Microsoft\\Windows\\...' paths exist on down-level systems; passing a folder name without the leading backslash.","solutions":["Verify the folder path exists before lookup (catch this ArgumentException)","Use the leading '\\' and exact casing in the path","Iterate SubFolders to check available names instead of guessing paths"],"exampleFix":"// before\nvar folder = ts.GetFolder(\"\\\\MyApp\\Tasks\");\n// after\nTaskFolder folder = null;\ntry { folder = ts.GetFolder(\"\\\\MyApp\\Tasks\"); }\ncatch (ArgumentException) { folder = ts.RootFolder.CreateFolder(\"\\\\MyApp\\Tasks\"); }","handlingStrategy":"try-catch","validationCode":"static bool FolderExists(TaskService ts, string path) {\n    if (string.IsNullOrEmpty(path) || path == \"\\\\\") return true;\n    try { ts.GetFolder(path); return true; } catch (ArgumentException) { return false; }\n}","typeGuard":null,"tryCatchPattern":"try { folder = ts.GetFolder(path); }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"Path not found\")) { folder = ts.RootFolder; }","preventionTips":["Always prefix folder paths with '\\'","Enumerate RootFolder/SubFolders to discover valid paths instead of guessing","Cache resolved TaskFolder references instead of repeated lookups"],"tags":["task-scheduler","path-not-found","argumentexception"],"backgroundTag":"folder-path-not-found","analyzedSha":"53fb989abc2219826385683a6fee826bd6cd38d6","analyzedAt":"2026-09-02T04:25:09.259Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T11:17:12.671Z"}