{"record":{"id":"bdd22bd418f61ae0","repo":"BCUninstaller/Bulk-Crap-Uninstaller","slug":"multiple-commands-specified","errorCode":null,"errorMessage":"Multiple commands specified","messagePattern":"Multiple commands specified","errorType":"validation","errorClass":"FormatException","httpStatus":null,"severity":"error","filePath":"source/ScriptHelper/Program.cs","lineNumber":73,"sourceCode":"                return (int)ResultWin32.ERROR_BAD_ARGUMENTS;\n            }\n            catch (Exception ex)\n            {\n                LogWriter.WriteExceptionToLog(ex);\n                return (int)ResultWin32.ERROR_UNEXP_NET_ERR;\n            }\n            return (int)ResultWin32.ERROR_SUCCESS;\n        }\n\n        private static void ProcessCommandlineArguments(IEnumerable<string> args)\n        {\n            foreach (var arg in args)\n            {\n                switch (arg.ToLowerInvariant())\n                {\n                    case @\"u\":\n                    case @\"uninstall\":\n                        if (_queryType != QueryType.None) throw new FormatException(@\"Multiple commands specified\");\n                        _queryType = QueryType.Uninstall;\n                        break;\n\n                    case @\"l\":\n                    case @\"list\":\n                        if (_queryType != QueryType.None) throw new FormatException(@\"Multiple commands specified\");\n                        _queryType = QueryType.List;\n                        break;\n\n                    default:\n                        if (_appId != null) throw new FormatException(@\"Too many parameters\");\n                        _appId = arg;\n                        break;\n                }\n            }\n\n            if (_queryType == QueryType.None)\n                throw new FormatException(@\"No commands specified\");","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/BCUninstaller/Bulk-Crap-Uninstaller/blob/608321de98e92297377b1eb69029af55c25504a1/source/ScriptHelper/Program.cs#L55-L91","documentation":"Thrown by ProcessCommandlineArguments when the 'uninstall' (or 'u') flag is encountered but _queryType is already set to a command other than None. The parser allows exactly one command verb per invocation; a second verb triggers FormatException, which Main maps to ResultWin32.ERROR_BAD_ARGUMENTS.","triggerScenarios":"Running ScriptHelper with two command verbs where the first is 'uninstall'/'u', e.g. 'ScriptHelper uninstall list' or 'ScriptHelper u l'.","commonSituations":"Quoting or concatenating multiple commands by mistake in a batch file; passing a help/usage string that itself contains a recognized verb; downstream tools appending extra flags that look like verbs.","solutions":["Pass exactly one command verb ('list' or 'uninstall') per invocation.","Validate argv before spawning ScriptHelper so at most one verb is present.","If you need both behaviors, invoke ScriptHelper twice rather than combining verbs."],"exampleFix":"// before\nScriptHelper.exe uninstall list MyApp\n// -> FormatException: Multiple commands specified\n\n// after\nScriptHelper.exe uninstall MyApp\nScriptHelper.exe list","handlingStrategy":"validation","validationCode":"var verbs = args.Where(a => a is \"u\" or \"uninstall\" or \"l\" or \"list\").ToList();\nif (verbs.Count > 1)\n    throw new ArgumentException(\"Pass at most one command verb to ScriptHelper.\");","typeGuard":null,"tryCatchPattern":"try { ProcessCommandlineArguments(args); }\ncatch (FormatException ex) when (ex.Message.Contains(\"Multiple commands\"))\n{ /* user passed >1 verb; print usage */ }","preventionTips":["Pass exactly one command verb per ScriptHelper invocation.","Sanitize argv in the caller to drop duplicate verbs.","Invoke separate processes for 'list' and 'uninstall'."],"tags":["script-helper","cli","argument-parsing","csharp"],"backgroundTag":null,"analyzedSha":"608321de98e92297377b1eb69029af55c25504a1","analyzedAt":"2026-08-13T12:17:35.389Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}