winget-cli icon indicating copy to clipboard operation
winget-cli copied to clipboard

Document Exit Codes

Open sirinath opened this issue 3 years ago • 5 comments

Brief description of your issue

Please document the exit codes so WinGet can be used in batch files.

sirinath avatar Dec 05 '21 08:12 sirinath

If you are referring to exit codes coming from installers, they could be nearly anything. The exit codes from MSIX, and MSI installers are well documented. For EXE installers, it depends on the publisher when they package their application. We do have an ability to map expected return codes from EXE installers to more standardized error codes in the manifest.

  • #1278

Is this what you are referring to?

denelon avatar Dec 06 '21 17:12 denelon

I think they mean the exit codes returned by winget itself, not the installers, i.e. the ones defined in AppInstallerErrors.h Something like "0x8A150008 means that downloading the installer failed; 0x8A150109 means that the installer needs a reboot to finish; etc." So somebody could call winget in a script, and handle each error differently.

florelis avatar Dec 06 '21 19:12 florelis

@lechacon exactly

sirinath avatar Dec 07 '21 03:12 sirinath

+1

panther7 avatar Jan 18 '23 10:01 panther7

To put a little more meat on this problem - it's not uncommon that a bit of a script might have a goal like: "Ensure that such&such a package is installed and at the latest version". Right now, if you want to validate that the installation happened, you have to check your exit code against everything that the installer might do (which can often be summed up by 'if it returns 0, it succeeded') plus everything that WinGet might do. If WinGet decides the package is already current and up-to-date, it exits with APPINSTALLER_CLI_ERROR_UPDATE_NOT_APPLICABLE, so an install script has to check not just against zero, but also against -1978335189.

SteveBenz avatar Feb 07 '23 22:02 SteveBenz

PR https://github.com/microsoft/winget-cli/pull/3202 added a doc listing exit codes returned by WinGet

https://github.com/microsoft/winget-cli/blob/master/doc/windows/package-manager/winget/returnCodes.md

cc @denelon if this needs to be closed

mdanish-kh avatar May 11 '23 19:05 mdanish-kh

https://github.com/microsoft/winget-cli/blob/master/doc/windows/package-manager/winget/returnCodes.md

denelon avatar May 11 '23 20:05 denelon