{"record":{"id":"512cbc36a459d8ee","repo":"memstechtips/Winhance","slug":"adk-installation-failed-with-exit-code-exitcode","errorCode":null,"errorMessage":"ADK installation failed with exit code: {exitCode}","messagePattern":"ADK installation failed with exit code: (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/Winhance.Infrastructure/Features/AdvancedTools/Services/OscdimgToolManager.cs","lineNumber":226,"sourceCode":"\r\n            progress?.Report(new TaskProgressDetail\r\n            {\r\n                StatusText = _localization.GetString(\"Progress_InstallingAdkTools\"),\r\n                TerminalOutput = \"This may take several minutes\"\r\n            });\r\n\r\n            var logPath = _fileSystemService.CombinePath(_fileSystemService.GetTempPath(), \"adk_install.log\");\r\n            var arguments = $\"/quiet /norestart /features OptionId.DeploymentTools /ceip off /log \\\"{logPath}\\\"\";\r\n\r\n            progress?.Report(new TaskProgressDetail\r\n            {\r\n                TerminalOutput = \"Starting ADK Deployment Tools installation...\"\r\n            });\r\n\r\n            var (exitCode, _) = await _dismProcessRunner.RunProcessWithProgressAsync(adkSetupPath, arguments, progress, cancellationToken).ConfigureAwait(false);\r\n            if (exitCode != 0)\r\n            {\r\n                throw new Exception($\"ADK installation failed with exit code: {exitCode}\");\r\n            }\r\n\r\n            if (await IsOscdimgAvailableAsync().ConfigureAwait(false))\r\n            {\r\n                _logService.LogInformation(\"ADK installed and oscdimg.exe found\");\r\n                return true;\r\n            }\r\n\r\n            _logService.LogError(\"ADK installed but oscdimg.exe not found\");\r\n            return false;\r\n        }\r\n        catch (Exception ex)\r\n        {\r\n            _logService.LogError($\"Error installing ADK: {ex.Message}\", ex);\r\n            return false;\r\n        }\r\n        finally\r\n        {\r","sourceCodeStart":208,"sourceCodeEnd":244,"githubUrl":"https://github.com/memstechtips/Winhance/blob/f23d554eb2d6400b1827bcc46b91294ffa53fbc9/src/Winhance.Infrastructure/Features/AdvancedTools/Services/OscdimgToolManager.cs#L208-L244","documentation":"The Windows ADK setup (adksetup.exe) was launched with /quiet /norestart /features OptionId.DeploymentTools but exited non-zero, meaning the ADK Deployment Tools (which provide oscdimg.exe) did not install. The message reports only the exit code; adksetup wrote detailed reasons to %temp%\\adk_install.log.","triggerScenarios":"InstallA dkAsync (OscdimgToolManager) invokes adksetup.exe with the quiet DeploymentTools feature set and RunProcessWithProgressAsync returns exitCode != 0. Typical adksetup non-zero causes: insufficient disk space, a pending reboot from a prior install, missing prerequisites (e.g. .NET), network failure downloading payloads, or the ADK version mismatched to the OS.","commonSituations":"A previous install/uninstall left a pending-reboot state. The machine is on an older Windows build than the ADK targets. Corporate proxy blocks the ADK payload download. Disk full on the system drive. adksetup.exe was launched from a path without write access for the log.","solutions":["Open %temp%\\adk_install.log and read the ERROR lines — adksetup logs the exact failure reason and component.","Reboot the machine to clear any pending-reboot state from prior installs, then retry.","Free disk space on the system drive (ADK Deployment Tools need several GB during install).","Download the matching ADK version for your Windows build from Microsoft and run adksetup manually to surface the UI error.","If network/proxy is blocking payloads, pre-download the full ADK offline installer and point the flow at that."],"exampleFix":"// before\nif (exitCode != 0)\n    throw new Exception($\"ADK installation failed with exit code: {exitCode}\");\n\n// after: include the log path so the user knows where to look\nif (exitCode != 0)\n    throw new Exception($\"ADK installation failed with exit code {exitCode}. See log: {logPath}\");","handlingStrategy":"try-catch","validationCode":"// Before invoking ADK install, check pending-reboot and disk space.\nbool CanInstallAdk(string systemDrive) =>\n    !IsRebootPending() && HasFreeGigabytes(systemDrive, 5);\n\nbool IsRebootPending() =>\n    Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@\"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Component Based Servicing\\RebootPending\") != null;","typeGuard":null,"tryCatchPattern":"catch (Exception ex) when (ex.Message.Contains(\"ADK installation failed\"))\n{\n    // Read %temp%\\\\adk_install.log for the real reason; advise reboot / free space / offline installer.\n}","preventionTips":["Reboot before installing ADK if a prior install left a pending state.","Keep several GB free on the system drive for ADK Deployment Tools.","Use the offline (full) ADK installer on machines behind proxies."],"tags":["installer","adk","external-process","windows","prerequisite"],"backgroundTag":null,"analyzedSha":"f23d554eb2d6400b1827bcc46b91294ffa53fbc9","analyzedAt":"2026-08-13T17:55:20.922Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}