{"record":{"id":"1ac4dc09434a8ad5","repo":"chocolatey/choco","slug":"reboot-required-before-continuing-reboot-and-run","errorCode":null,"errorMessage":"Reboot required before continuing. Reboot and run the same command again.","messagePattern":"Reboot required before continuing\\. Reboot and run the same command again\\.","errorType":"exception","errorClass":"ApplicationException","httpStatus":null,"severity":"critical","filePath":"src/chocolatey/infrastructure.app/services/ChocolateyPackageService.cs","lineNumber":584,"sourceCode":"\r\n            pkgInfo.DeploymentLocation = Environment.GetEnvironmentVariable(EnvironmentVariables.Package.ChocolateyPackageInstallLocation);\r\n            pkgInfo.SourceInstalledFrom = packageResult.SourceInstalledFrom;\r\n\r\n            UpdatePackageInformation(pkgInfo);\r\n            EnsureBadPackagesPathIsClean(packageResult);\r\n            EventManager.Publish(new HandlePackageResultCompletedMessage(packageResult, config, commandName));\r\n\r\n            UnmarkPackagePending(packageResult, config);\r\n\r\n            if (_rebootExitCodes.Contains(packageResult.ExitCode))\r\n            {\r\n                if (config.Features.ExitOnRebootDetected)\r\n                {\r\n                    Environment.ExitCode = ApplicationParameters.ExitCodes.ErrorInstallSuspend;\r\n                    this.Log().Warn(ChocolateyLoggers.Important, @\"Chocolatey has detected a pending reboot after installing/upgrading\r\npackage '{0}' - stopping further execution\".FormatWith(packageResult.Name));\r\n\r\n                    throw new ApplicationException(\"Reboot required before continuing. Reboot and run the same command again.\");\r\n                }\r\n            }\r\n\r\n            if (!packageResult.Success)\r\n            {\r\n                this.Log().Error(ChocolateyLoggers.Important, \"The {0} of {1} was NOT successful.\".FormatWith(commandName.ToStringSafe(), packageResult.Name));\r\n                HandleFailedOperation(config, packageResult, movePackageToFailureLocation: true, attemptRollback: true);\r\n\r\n                if (config.Features.StopOnFirstPackageFailure)\r\n                {\r\n                    throw new ApplicationException(\"Stopping further execution as {0} has failed {1}.\".FormatWith(packageResult.Name, commandName.ToStringSafe()));\r\n                }\r\n\r\n                return;\r\n            }\r\n\r\n            RemoveBackupIfExists(packageResult);\r\n\r","sourceCodeStart":566,"sourceCodeEnd":602,"githubUrl":"https://github.com/chocolatey/choco/blob/0d5abdd10cc177a141e69547cad6935b419b6c17/src/chocolatey/infrastructure.app/services/ChocolateyPackageService.cs#L566-L602","documentation":"Thrown as an ApplicationException during HandlePackageResult (install/upgrade flow) when the package installer returns an exit code in _rebootExitCodes (1641 or 3010) AND config.Features.ExitOnRebootDetected is enabled. The environment exit code is first set to ApplicationParameters.ExitCodes.ErrorInstallSuspend (ERROR_INSTALL_SUSPEND), a warning is logged, then this exception halts all further package processing.","triggerScenarios":"An installer embedded in a Chocolatey package exits with code 1641 (ERROR_SUCCESS_REBOOT_INITIATED) or 3010 (ERROR_SUCCESS_REBOOT_REQUIRED) while config.Features.ExitOnRebootDetected is true. This occurs inside HandlePackageResult after the package has been processed and UnmarkPackagePending has been called.","commonSituations":"Installing or upgrading a package (e.g., a driver, .NET runtime, or system update MSI) that requires a reboot. The 'exitOnRebootDetected' feature flag is enabled, causing Chocolatey to stop mid-batch instead of continuing to the next package.","solutions":["Reboot the machine, then re-run the same choco command — Chocolatey resumes from where it stopped.","If unattended and reboots are handled externally, disable the feature: 'choco feature disable --name=exitOnRebootDetected' so Chocolatey continues past reboot exit codes.","Ensure packages that report reboot exit codes are ordered last in batch installs, or split them into a separate install run.","Capture and handle the ErrorInstallSuspend exit code in your automation script to trigger a reboot cycle."],"exampleFix":"// before: feature enabled, halts on reboot exit codes\nchoco feature enable --name=exitOnRebootDetected\nchoco upgrade all -y\n\n// after: disable feature for unattended scenarios, or reboot and re-run\ndism /online /Reboot /Quiet  # or shutdown /r /t 0\nchoco upgrade all -y","handlingStrategy":"validation","validationCode":"// Check reboot exit codes and feature flag before expecting install to complete\nvar rebootExitCodes = new[] { 1641, 3010 };\nif (config.Features.ExitOnRebootDetected)\n{\n    // Warn automation that a reboot may halt execution\n    logger.Info(\"exitOnRebootDetected is enabled — installs may halt if a reboot is required.\");\n}\n// After install, check if exit code indicates reboot needed\nif (rebootExitCodes.Contains(Environment.ExitCode))\n{\n    // Schedule reboot and re-run\n    logger.Warn(\"Reboot required. Schedule restart and re-run the command.\");\n}","typeGuard":null,"tryCatchPattern":"try\n{\n    _packageService.Install(config);\n}\ncatch (ApplicationException ex) when (ex.Message.Contains(\"Reboot required\"))\n{\n    // ExitCode is already set to ErrorInstallSuspend\n    // Trigger reboot in automation, then re-run the same command\n    ScheduleRebootAndRerun();\n}","preventionTips":["In automation scripts, check for exit code 1641 or 3010 after choco commands and handle reboot cycles.","For unattended scenarios where reboots are handled externally, disable exitOnRebootDetected.","Order packages that may require reboots last in batch installs.","Document which packages are known to trigger reboot exit codes."],"tags":["reboot","install","exit-code","exitonrebootdetected","chocolatey"],"backgroundTag":null,"analyzedSha":"0d5abdd10cc177a141e69547cad6935b419b6c17","analyzedAt":"2026-08-13T18:33:03.301Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}