{"record":{"id":"d990f27989830381","repo":"BCUninstaller/Bulk-Crap-Uninstaller","slug":"failed-to-open-regedit-exe","errorCode":null,"errorMessage":"Failed to open regedit.exe","messagePattern":"Failed to open regedit\\.exe","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"source/KlocTools/Tools/RegistryTools.cs","lineNumber":458,"sourceCode":"        {\n            try\n            {\n                if (!ProcessTools.SafeKillProcess(\"regedit\"))\n                    throw new IOException(\"Could not close running instance of Regedit\");\n\n                var regeditSettings =\n                    Registry.CurrentUser.CreateSubKey(@\"Software\\Microsoft\\Windows\\CurrentVersion\\Applets\\Regedit\",\n                        RegistryKeyPermissionCheck.ReadWriteSubTree);\n\n                if (regeditSettings == null)\n                    throw new IOException(\"Failed to set the last user registry key\");\n\n                regeditSettings.SetValue(\"LastKey\", registryPath, RegistryValueKind.String);\n                Process.Start(\"regedit.exe\");\n            }\n            catch (Exception ex)\n            {\n                throw new IOException(\"Failed to open regedit.exe\", ex);\n            }\n        }\n    }\n}","sourceCodeStart":440,"sourceCodeEnd":462,"githubUrl":"https://github.com/BCUninstaller/Bulk-Crap-Uninstaller/blob/608321de98e92297377b1eb69029af55c25504a1/source/KlocTools/Tools/RegistryTools.cs#L440-L462","documentation":"Thrown by OpenRegKeyInRegedit as a catch-all: any exception inside the try block that is not already re-thrown (the SafeKillProcess failure and null CreateSubKey cases) is wrapped in this IOException with the original as InnerException. The message is generic; inspect InnerException for the real cause.","triggerScenarios":"Process.Start(\"regedit.exe\") throwing (e.g. regedit not found, Win32Exception), SetValue throwing an UnauthorizedAccessException or IOException due to a locked key, or any other unexpected failure during the LastKey write or process launch.","commonSituations":"regedit.exe missing or blocked by policy; the Applets key locked by another process; transient registry I/O errors; antivirus blocking process launch.","solutions":["Catch this IOException and inspect ex.InnerException to identify the root cause.","Ensure regedit.exe is present and launchable from the process (PATH / system integrity).","Run elevated and in an interactive session so both the registry write and Process.Start succeed.","Retry transient registry I/O failures with backoff."],"exampleFix":"// before\nRegistryTools.OpenRegKeyInRegedit(path);\n\n// after\ntry { RegistryTools.OpenRegKeyInRegedit(path); }\ncatch (IOException ex)\n{\n    Log.Error(\"OpenRegKeyInRegedit failed\", ex.InnerException ?? ex);\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { RegistryTools.OpenRegKeyInRegedit(path); }\ncatch (IOException ex)\n{\n    var root = ex.InnerException ?? ex;\n    Log.Error($\"OpenRegKeyInRegedit failed: {root.GetType().Name}: {root.Message}\");\n}","preventionTips":["Always inspect InnerException - the outer message is generic.","Ensure regedit.exe is present and launchable.","Run elevated and in an interactive session for both registry write and process launch."],"tags":["registry","regedit","process","error-wrapping","windows","csharp"],"backgroundTag":null,"analyzedSha":"608321de98e92297377b1eb69029af55c25504a1","analyzedAt":"2026-08-13T12:17:35.389Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}