BCUninstaller/Bulk-Crap-Uninstaller · error · AutomatedUninstallException

Automatic uninstallation failed.

Error message

Automatic uninstallation failed.

What it means

This is the catch-all wrapper thrown by the catch(Exception) block in UninstallNsisQuietly. It wraps any exception that occurs during process start, the NSIS self-extraction wait (pr.WaitForExit), child-process lookup via ProcessTools.GetChildProcesses, or the fallback name-based process scan and Application.Attach. It is an AutomatedUninstallException carrying the original command, the inner exception, and whichever process (app or pr) was obtained, so callers get a single typed error with full context.

Source

Thrown at source/UninstallerAutomatizer/Automation/AutomatedUninstallManager.cs:135

                if (prs != 0)
                {
                    app = Application.Attach(prs);
                }
                else
                {
                    // Get all processes with name in format [A-Z]u_ (standard NSIS naming scheme, e.g. "Au_.exe") 
                    // and select the last one to launch. (Most likely to be ours)
                    var uninstallProcess = Process.GetProcesses()
                        .Where(x => x.ProcessName.Length == 3 && x.ProcessName.EndsWith("u_", StringComparison.Ordinal))
                        .OrderByDescending(x => x.StartTime).First();
                    app = Application.Attach(uninstallProcess);
                }
            }
            catch (Exception e)
            {
                var process = app != null ? ProcessTools.GetProcessByIdSafe(app.ProcessId) : null;
                throw new AutomatedUninstallException(Localization.Message_Automation_Failed, e, uninstallerCommand, process ?? pr);
            }

            if (app != null)
                AutomatizeApplication(app, statusCallback);
        }

        public static void AutomatizeApplication(Application app, Action<string> statusCallback)
        {
            if (app == null) throw new ArgumentNullException(nameof(app));
            if (statusCallback == null) throw new ArgumentNullException(nameof(statusCallback));

            var windows = new List<Window>();

            void VisibleChangedHandler(object sender, EventArgs args) => SetWindowVisibility(windows, HideAutomatizedWindows);
            HideAutomatizedWindowsChanged += VisibleChangedHandler;

            try
            {

View on GitHub (pinned to 608321de98)

Solutions

  1. Inspect the InnerException of the caught AutomatedUninstallException to find the real cause (InvalidOperationException 'Sequence contains no elements', access denied, etc.).
  2. Ensure the uninstaller is launched with the same elevation level it expects so the extracted child process is in a visible process tree.
  3. If GetChildProcesses returns 0 and no 'Xu_' process exists, the uninstaller may have completed or failed extraction; check its exit code before relying on attach.
  4. Run on a session with an interactive desktop; NSIS extraction launches a GUI child that cannot be enumerated from a non-interactive service account.

Example fix

// before - catch is generic and hides root cause from the caller
try { UninstallNsisQuietly(cmd, cb); }
catch (Exception e) { log(e.Message); }

// after - catch the typed wrapper and surface the inner exception
try { UninstallNsisQuietly(cmd, cb); }
catch (AutomatedUninstallException e)
{
    log($"{e.Message} (cmd={e.Command})");
    if (e.InnerException != null) log(e.InnerException);
}
Defensive patterns

Strategy: try-catch

Try / catch

try { AutomatedUninstallManager.UninstallNsisQuietly(cmd, cb); }
catch (AutomatedUninstallException ex)
{
    // ex.InnerException is the real cause; ex.Command and ex.Process give context.
    Log(ex.InnerException ?? ex);
}

Prevention

When it happens

Trigger: pr.WaitForExit() never returns or the extractor crashes; ProcessTools.GetChildProcesses(pr.Id).FirstOrDefault() returns 0 AND the fallback Process.GetProcesses().Where(...EndsWith("u_")).OrderByDescending(StartTime).First() throws InvalidOperationException because no matching NSIS process exists (sequence contains no elements). Application.Attach fails because the extracted process already exited or access is denied. Any underlying FlaUI/White exception during attach.

Common situations: The NSIS uninstaller extracted then closed too fast for GetChildProcesses/GetProcesses to catch it. Another application happens to match the [A-Z]u_ naming scheme and is picked up, then fails to attach. The uninstaller prompted for elevation and the elevated copy is a different process tree invisible to the current token. Timing races on slow VMs where extraction is slow but child enumeration returns empty.

Related errors


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