BCUninstaller/Bulk-Crap-Uninstaller · error · FormatException

Multiple commands specified

Error message

Multiple commands specified

What it means

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.

Source

Thrown at source/ScriptHelper/Program.cs:73

                return (int)ResultWin32.ERROR_BAD_ARGUMENTS;
            }
            catch (Exception ex)
            {
                LogWriter.WriteExceptionToLog(ex);
                return (int)ResultWin32.ERROR_UNEXP_NET_ERR;
            }
            return (int)ResultWin32.ERROR_SUCCESS;
        }

        private static void ProcessCommandlineArguments(IEnumerable<string> args)
        {
            foreach (var arg in args)
            {
                switch (arg.ToLowerInvariant())
                {
                    case @"u":
                    case @"uninstall":
                        if (_queryType != QueryType.None) throw new FormatException(@"Multiple commands specified");
                        _queryType = QueryType.Uninstall;
                        break;

                    case @"l":
                    case @"list":
                        if (_queryType != QueryType.None) throw new FormatException(@"Multiple commands specified");
                        _queryType = QueryType.List;
                        break;

                    default:
                        if (_appId != null) throw new FormatException(@"Too many parameters");
                        _appId = arg;
                        break;
                }
            }

            if (_queryType == QueryType.None)
                throw new FormatException(@"No commands specified");

View on GitHub (pinned to 608321de98)

Solutions

  1. Pass exactly one command verb ('list' or 'uninstall') per invocation.
  2. Validate argv before spawning ScriptHelper so at most one verb is present.
  3. If you need both behaviors, invoke ScriptHelper twice rather than combining verbs.

Example fix

// before
ScriptHelper.exe uninstall list MyApp
// -> FormatException: Multiple commands specified

// after
ScriptHelper.exe uninstall MyApp
ScriptHelper.exe list
Defensive patterns

Strategy: validation

Validate before calling

var verbs = args.Where(a => a is "u" or "uninstall" or "l" or "list").ToList();
if (verbs.Count > 1)
    throw new ArgumentException("Pass at most one command verb to ScriptHelper.");

Try / catch

try { ProcessCommandlineArguments(args); }
catch (FormatException ex) when (ex.Message.Contains("Multiple commands"))
{ /* user passed >1 verb; print usage */ }

Prevention

When it happens

Trigger: Running ScriptHelper with two command verbs where the first is 'uninstall'/'u', e.g. 'ScriptHelper uninstall list' or 'ScriptHelper u l'.

Common situations: 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.

Related errors


AI-assisted analysis of BCUninstaller/Bulk-Crap-Uninstaller@608321de98 (2026-08-13). Data as JSON: /api/errors/bdd22bd418f61ae0. Report an issue: GitHub.