memstechtips/Winhance · error · Exception

ADK installation failed with exit code: {exitCode}

Error message

ADK installation failed with exit code: {exitCode}

What it means

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.

Source

Thrown at src/Winhance.Infrastructure/Features/AdvancedTools/Services/OscdimgToolManager.cs:226

            progress?.Report(new TaskProgressDetail
            {
                StatusText = _localization.GetString("Progress_InstallingAdkTools"),
                TerminalOutput = "This may take several minutes"
            });

            var logPath = _fileSystemService.CombinePath(_fileSystemService.GetTempPath(), "adk_install.log");
            var arguments = $"/quiet /norestart /features OptionId.DeploymentTools /ceip off /log \"{logPath}\"";

            progress?.Report(new TaskProgressDetail
            {
                TerminalOutput = "Starting ADK Deployment Tools installation..."
            });

            var (exitCode, _) = await _dismProcessRunner.RunProcessWithProgressAsync(adkSetupPath, arguments, progress, cancellationToken).ConfigureAwait(false);
            if (exitCode != 0)
            {
                throw new Exception($"ADK installation failed with exit code: {exitCode}");
            }

            if (await IsOscdimgAvailableAsync().ConfigureAwait(false))
            {
                _logService.LogInformation("ADK installed and oscdimg.exe found");
                return true;
            }

            _logService.LogError("ADK installed but oscdimg.exe not found");
            return false;
        }
        catch (Exception ex)
        {
            _logService.LogError($"Error installing ADK: {ex.Message}", ex);
            return false;
        }
        finally
        {

View on GitHub (pinned to f23d554eb2)

Solutions

  1. Open %temp%\adk_install.log and read the ERROR lines — adksetup logs the exact failure reason and component.
  2. Reboot the machine to clear any pending-reboot state from prior installs, then retry.
  3. Free disk space on the system drive (ADK Deployment Tools need several GB during install).
  4. Download the matching ADK version for your Windows build from Microsoft and run adksetup manually to surface the UI error.
  5. If network/proxy is blocking payloads, pre-download the full ADK offline installer and point the flow at that.

Example fix

// before
if (exitCode != 0)
    throw new Exception($"ADK installation failed with exit code: {exitCode}");

// after: include the log path so the user knows where to look
if (exitCode != 0)
    throw new Exception($"ADK installation failed with exit code {exitCode}. See log: {logPath}");
Defensive patterns

Strategy: try-catch

Validate before calling

// Before invoking ADK install, check pending-reboot and disk space.
bool CanInstallAdk(string systemDrive) =>
    !IsRebootPending() && HasFreeGigabytes(systemDrive, 5);

bool IsRebootPending() =>
    Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootPending") != null;

Try / catch

catch (Exception ex) when (ex.Message.Contains("ADK installation failed"))
{
    // Read %temp%\\adk_install.log for the real reason; advise reboot / free space / offline installer.
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of memstechtips/Winhance@f23d554eb2 (2026-08-13). Data as JSON: /api/errors/512cbc36a459d8ee. Report an issue: GitHub.