> ## Documentation Index
> Fetch the complete documentation index at: /docs/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Bach builds Windows installers from one bach.toml with the bach command: bach init, bach check, bach preview, bach build. Installs are per user and need no administrator rights by default. installer.scope = "machine" installs for every user after one Windows prompt. On Windows, run setup files with Start-Process -Wait -PassThru in PowerShell, and give signtool arguments that start with the word sign.

# Exit codes of setup files and the bach command

> The exit codes of a silent install, a silent removal, uninstall.exe --check-update and the bach command, so scripts and IT tools can react correctly.

Scripts and IT tools decide what to do from a program's exit code. This page lists what setup files, the uninstaller and the `bach` command return.

## Setup file and uninstaller

| Code | Meaning | Applies to |
| - | - | - |
| `0` | Done. The install, update or removal finished. | `--silent` runs |
| `1` | Failed. The reason is printed in a terminal and written to the log. | `--silent` runs |
| `2` | A command-line mistake: an unknown flag, a stray word, a flag without its value, a bad `--theme` or `--wait-for`, or a missing access key. See [How the command line is read](/docs/reference/setup/command-line.md#how-the-command-line-is-read). | every run, `--silent` or not |
| `10` | A newer version is available (it is printed) | `uninstall.exe --check-update` |
| `0` | Up to date | `uninstall.exe --check-update` |
| `1` | The feed could not be read | `uninstall.exe --check-update` |
| `10` | A newer version was downloaded and is ready (or, for `--auto-update`, is ready but the app is open) | `--download-update`, `--auto-update` |
| `0` | Installed, or there was nothing to do | `--apply-update`, `--auto-update` |
| `1` | It could not be installed yet, or must not run. A download that fails its checks is deleted; otherwise it stays ready for the next try. | `--apply-update` |
| `2` | The app has no `[updates]` section | the update flags |

`uninstall.exe --update --silent` exits with the code of the setup it ran.

A silent run exits with `1` when:

* a [requirement](/docs/guides/requirements.md) is missing,
* the install is older than the one on the computer and `--allow-downgrade` was not passed,
* a first install would replace files that are already in the folder and `--overwrite` was not passed,
* the app is open, another setup for it is running, the disk is full, or a file could not be written.

The reason is printed to the terminal and appended to the log at `%TEMP%\<app id>-setup.log`, or the file given with `--log`.

## The bach command

| Code | Meaning |
| - | - |
| `0` | The command succeeded |
| non-zero | The command failed. A readable sentence is printed. |

Because every failure produces a non-zero code and one clear sentence, `bach build` and `bach check` work in pipelines as they are.

## Using it

```powershell theme={"theme":{"light":"github-light","dark":"github-dark"}}
$p = Start-Process ".\Hello-Setup-1.4.0.exe" -ArgumentList "--silent" -Wait -PassThru
if ($p.ExitCode -ne 0) { Get-Content "$env:TEMP\Hello-setup.log" -Tail 20 }
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.