BCUninstaller/Bulk-Crap-Uninstaller · error · IOException

regedit.exe failed to execute properly

Error message

regedit.exe failed to execute properly

What it means

Thrown by RunRegeditCommand when regedit.exe does not exit within 50000 ms. The helper waits up to 50 seconds for the spawned regedit process; on timeout it kills the process and raises this IOException. It is a fatal, non-retryable outcome from the helper's perspective (the process is already terminated).

Source

Thrown at source/KlocTools/Tools/RegistryTools.cs:403

        }

        private static void RunRegeditCommand(string command)
        {
            foreach (var process in Process.GetProcessesByName("regedit"))
            {
                try { process.Kill(); }
                catch (InvalidOperationException) { }
                catch (Win32Exception) { }
            }

            var startInfo = new ProcessStartInfo("regedit.exe", command)
            { UseShellExecute = false };
            var pr = startInfo.Start();

            if (!pr.WaitForExit(50000))
            {
                pr.Kill();
                throw new IOException("regedit.exe failed to execute properly");
            }
            if (pr.ExitCode != 0)
                throw new IOException("regedit.exe returned error code: " + pr.ExitCode);
        }

        private static string[] ExportRegistryHelper(string registryPath)
        {
            // Check if the key exists
            try
            {
                OpenRegistryKey(registryPath).Close();
            }
            catch
            {
                return null;
            }

            var temp = Path.GetTempPath();

View on GitHub (pinned to 608321de98)

Solutions

  1. Ensure no interactive regedit dialogs are pending (the helper kills prior regedit instances first, but external UAC prompts can still block).
  2. Reduce the scope of the export so regedit finishes well under 50 s.
  3. Run the process elevated and with an accessible temp directory (the helper uses %TEMP%\\BCU\\tempBackup.reg).
  4. If 50 s is genuinely too short for your workload, fork the helper and raise the WaitForExit timeout or run regedit asynchronously.

Example fix

// before (uses RunRegeditCommand via ExportRegistryHelper, 50s hard cap)
var lines = ExportRegistryHelper(bigSubtreePath);

// after (export a narrower key, or call reg.exe directly with your own timeout)
var lines = ExportRegistryHelper("HKLM\\SOFTWARE\\MyApp");
Defensive patterns

Strategy: retry

Validate before calling

// Pre-check the key exists and is readable, and that no regedit dialog is pending.
if (RegistryTools.OpenRegistryKey(registryPath) == null) return null;

Try / catch

try { var lines = ExportRegistryHelper(path); }
catch (IOException ex) when (ex.Message.Contains("failed to execute properly"))
{ /* regedit was killed; report timeout, optionally retry with a narrower key */ }

Prevention

When it happens

Trigger: Calling ExportRegistryHelper (or any code path that invokes RunRegeditCommand) when regedit.exe hangs, is blocked by a dialog (e.g. UAC, overwrite confirmation), is deadlocked on a locked file, or the system is under heavy load so regedit never returns within 50 s.

Common situations: A previous regedit instance holding a lock; antivirus scanning tempBackup.reg; exporting a very large registry subtree that exceeds the timeout; running as a user without permission, causing regedit to wait on a prompt it cannot show.

Related errors


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