BCUninstaller/Bulk-Crap-Uninstaller · error · ArgumentException

File name can't be empty.

Error message

File name can't be empty.

What it means

Thrown by ProcessTools.SeparateArgsFromCommand(string fullCommand). After a null check and Trim(), if the command string is empty the method throws ArgumentException(Localisation.Error_SeparateArgsFromCommand_Empty, nameof(fullCommand)) — the localised value is "File name can't be empty.". Whitespace-only strings are trimmed to empty and also trigger this.

Source

Thrown at source/KlocTools/Tools/ProcessTools.cs:144

        //static readonly char[] pathFilterChars = StringTools.InvalidPathChars.Except(new char[] { '"' }).ToArray();
        /// <summary>
        ///     Attempts to separate filename (or filename with path) from the supplied arguments.
        /// </summary>
        /// <param name="fullCommand"></param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException">The value of 'fullCommand' cannot be null. </exception>
        /// <exception cref="ArgumentException">fullCommand can't be empty</exception>
        /// <exception cref="FormatException">Filename is in invalid format</exception>
        public static ProcessStartCommand SeparateArgsFromCommand(string fullCommand)
        {
            if (fullCommand == null)
                throw new ArgumentNullException(nameof(fullCommand));

            // Get rid of whitespaces
            fullCommand = fullCommand.Trim();

            if (string.IsNullOrEmpty(fullCommand))
                throw new ArgumentException(Localisation.Error_SeparateArgsFromCommand_Empty, nameof(fullCommand));

            var firstDot = fullCommand.IndexOf('.');
            if (firstDot < 0)
                return SeparateNonDottedCommand(fullCommand);

            // Check if the path is in format: ExecutableName C:\Argname.exe
            {
                var pathRoot = fullCommand.IndexOf(":\\", StringComparison.InvariantCulture);
                var firstSpace = fullCommand.IndexOf(' ');
                if (firstSpace >= 0 && firstSpace < pathRoot)
                {
                    var filenameBreaker = fullCommand.IndexOfAny(SeparateArgsFromCommandInvalidChars, 0, pathRoot - 1);
                    if (filenameBreaker < 0)
                    {
                        var slashIndex = fullCommand.IndexOf('\\');
                        if (slashIndex >= 0 && slashIndex > pathRoot)
                        {
                            var rootSpace = fullCommand.LastIndexOf(' ', pathRoot);

View on GitHub (pinned to 608321de98)

Solutions

  1. Guard with string.IsNullOrWhiteSpace(fullCommand) at the call site and treat blank as 'no command'.
  2. Trim earlier in the pipeline and skip processing if empty.
  3. Provide a meaningful default command when the configured one is blank.

Example fix

// before
var cmd = ProcessTools.SeparateArgsFromCommand(raw); // raw may be "   "

// after
if (string.IsNullOrWhiteSpace(raw)) return null;
var cmd = ProcessTools.SeparateArgsFromCommand(raw);
Defensive patterns

Strategy: validation

Validate before calling

if (string.IsNullOrWhiteSpace(fullCommand)) return null;
var cmd = ProcessTools.SeparateArgsFromCommand(fullCommand);

Type guard

static bool IsNonEmptyCommand(string s) => !string.IsNullOrWhiteSpace(s);

Prevention

When it happens

Trigger: Calling SeparateArgsFromCommand with an all-whitespace string (e.g. " ", "\t") after the explicit null check has already handled null.

Common situations: Persisted command-line settings that were saved blank, UI fields the user cleared, or strings read from a file/registry whose value is just spaces.

Related errors


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