{"record":{"id":"a7dd73e9f1a55dfc","repo":"BCUninstaller/Bulk-Crap-Uninstaller","slug":"uninstaller-returned-error-code-exitvar","errorCode":null,"errorMessage":"Uninstaller returned error code: {exitVar}","messagePattern":"Uninstaller returned error code: (.+?)","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"source/UninstallTools/Uninstaller/BulkUninstallEntry.cs","lineNumber":450,"sourceCode":"                            else\r\n                            {\r\n                                switch (exitVar)\r\n                                {\r\n                                    case 2:\r\n                                        throw new Exception(\"The system cannot find the file specified. Indicates that the file can not be found in specified location.\");\r\n                                    case 3:\r\n                                        throw new Exception(\"The system cannot find the path specified. Indicates that the specified path can not be found.\");\r\n                                    case 5:\r\n                                        throw new Exception(\"Access is denied. Indicates that user has no access right to specified resource.\");\r\n                                    case 9009:\r\n                                        throw new Exception(\"Program is not recognized as an internal or external command, operable program or batch file.\");\r\n                                    case -2147024846:\r\n                                        throw new Exception(\"0x80070032 - This app is part of Windows and cannot be uninstalled on a per-user basis.\");\r\n\r\n                                    default:\r\n                                        if (options.RetryFailedQuiet || (UninstallerEntry.UninstallerKind == UninstallerType.Nsis && !options.PreferQuiet))\r\n                                            retry = true;\r\n                                        throw new IOException(Localisation.UninstallError_UninstallerReturnedCode + exitVar);\r\n                                }\r\n                            }\r\n                        }\r\n                    }\r\n                }\r\n            }\r\n            catch (Exception ex)\r\n            {\r\n                error = ex;\r\n                Trace.WriteLine(@$\"Exception when uninstalling {UninstallerEntry.DisplayName}: {ex}\");\r\n            }\r\n            finally\r\n            {\r\n                try\r\n                {\r\n                    _perfCounterBuffer.ForEach(x => x.Value.Dispose());\r\n                }\r\n                catch\r","sourceCodeStart":432,"sourceCodeEnd":468,"githubUrl":"https://github.com/BCUninstaller/Bulk-Crap-Uninstaller/blob/608321de98e92297377b1eb69029af55c25504a1/source/UninstallTools/Uninstaller/BulkUninstallEntry.cs#L432-L468","documentation":"The default case of the exit-code switch: exitVar did not match any of the known codes (2/3/5/9009/-2147024846) and is not a CTRL+C termination, so the code throws IOException with Localisation.UninstallError_UninstallerReturnedCode + exitVar. This is the generic 'uninstaller ran but reported a non-success, non-classified exit code' failure.","triggerScenarios":"The uninstaller process completed and returned an exit code the harness does not specifically decode — e.g. 1603 (MSI install/uninstall fatal error), 3010 (success-requires-reboot treated as error here), or any vendor-specific non-zero code.","commonSituations":"MSI uninstaller returns 1603 because a file was in use; NSIS installer returns its custom error code; a 'success but reboot required' (3010) lands here and is reported as a plain failure.","solutions":["Decode the numeric code: 1603 = fatal error (often locked files), 3010 = success-but-reboot (should be treated as success with a reboot prompt), consult the installer type's docs.","For 3010, special-case it as success-with-reboot instead of letting it fall through to this throw.","Run the same uninstaller with verbose logging (/qn /l*v for MSI) to capture why it returned a non-zero code."],"exampleFix":"// before\n// (library default case throws IOException with exitVar)\n\n// caller side: decode known codes before reporting\ntry { manager.RunUninstaller(entry, options); }\ncatch (IOException ex) when (exitVar == 3010)\n{\n    entry.MarkSuccessRequiresReboot();\n}\ncatch (IOException ex) when (exitVar == 1603)\n{\n    entry.MarkFailed(\"MSI fatal error — close the app and retry.\");\n}","handlingStrategy":"try-catch","validationCode":"null","typeGuard":"null","tryCatchPattern":"try { manager.RunUninstaller(entry, options); }\ncatch (IOException ex)\n{\n    var code = ExtractExitCode(ex.Message);\n    if (code == 3010) entry.MarkSuccessRequiresReboot();\n    else if (code == 1603) entry.MarkFailed(\"MSI fatal error; close the app and retry.\");\n    else throw;\n}","preventionTips":["Special-case 3010 as success-with-reboot instead of a generic failure.","For 1603, capture an MSI verbose log (/l*v) to find the failing action.","Decode unknown codes against the installer type's documentation before reporting."],"tags":["uninstaller","process-exit-code","io-exception","msi","exit-code-default"],"backgroundTag":null,"analyzedSha":"608321de98e92297377b1eb69029af55c25504a1","analyzedAt":"2026-08-13T12:17:35.389Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}