{"record":{"id":"bb35039666b5a8b5","repo":"BCUninstaller/Bulk-Crap-Uninstaller","slug":"dism-returned-error-code","errorCode":null,"errorMessage":"Dism returned error code ","messagePattern":"Dism returned error code ","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"source/KlocTools/IO/DismTools.cs","lineNumber":90,"sourceCode":"                UseShellExecute = false,\n                RedirectStandardOutput = true,\n                RedirectStandardError = false,\n                CreateNoWindow = true,\n                StandardOutputEncoding = Encoding.GetEncoding(850)\n            };\n\n            var process = Process.Start(psi);\n\n            Debug.Assert(process != null);\n            var output = process.StandardOutput.ReadToEnd();\n\n            process.WaitForExit();\n\n            if (process.ExitCode != 0)\n            {\n                var code = process.ExitCode.ToString();\n                var index = output.IndexOf(code, StringComparison.InvariantCulture);\n                throw new IOException(\"Dism returned error code \" + code,\n                    new Exception(index > 0 ? output.Substring(index + code.Length).Trim() : output));\n            }\n            return output;\n        }\n\n        public static WindowsFeatureInfo GetFeatureInfo(string featureName)\n        {\n            var output = RunDismCommand(\"/english /format:list /online /get-featureinfo /featurename=\" +\n                                        '\\\"' + featureName + '\\\"');\n\n            return FromDismOutput(output);\n        }\n\n        public static string GetDismUninstallString(string featureName, bool silent)\n        {\n            return string.Format(\"Dism.exe /norestart {1}/online /disable-feature /featurename=\\\"{0}\\\"\",\n                featureName, silent ? \"/quiet \" : string.Empty);\n        }","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/BCUninstaller/Bulk-Crap-Uninstaller/blob/608321de98e92297377b1eb69029af55c25504a1/source/KlocTools/IO/DismTools.cs#L72-L108","documentation":"RunDismCommand starts dism.exe, reads its stdout, and checks the exit code. Any non-zero code triggers IOException whose message names the code and whose InnerException carries the relevant DISM output snippet (located by searching for the code in the text). The caller can inspect the inner exception for DISM's own error description.","triggerScenarios":"DISM fails due to a missing feature name, corrupted component store, pending reboot, access denied, or unsupported operation.","commonSituations":"Querying a feature that does not exist; component-store corruption; a pending reboot blocking the operation; running non-elevated.","solutions":["Run BCU as administrator.","Address the specific DISM error (e.g. run sfc /scannow or DISM /RestoreHealth).","Reboot to clear a pending operation, then retry.","Verify the feature name actually exists on this image."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { return DismTools.GetFeatureInfo(name); }\ncatch (IOException ex) { var dismMsg = ex.InnerException?.Message; /* handle */ }","preventionTips":["Run DISM-based operations elevated.","Handle pending-reboot and component-store errors explicitly."],"tags":["dism","windows","external-process","error-code"],"backgroundTag":null,"analyzedSha":"608321de98e92297377b1eb69029af55c25504a1","analyzedAt":"2026-08-13T12:17:35.389Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}