> ## 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.

# Setup file command line: every flag a setup or uninstall.exe accepts

> Every flag a Bach setup file and an installed uninstall.exe understand: --silent, --dir, --with, --without, --lang, --log, --allow-downgrade, --update, --download-update, --apply-update and more.

Every setup file, and the `uninstall.exe` an install leaves behind, is the same runtime with a different payload, so they share one set of command-line flags. Flags are case-insensitive. This page lists all of them.

Setup files and `uninstall.exe` are windowed programs, so a shell does not wait for them and does not set an exit code. To wait and read the exit code, use `Start-Process`:

```powershell theme={"theme":{"light":"github-light","dark":"github-dark"}}
$p = Start-Process .\Hello-Setup-1.4.0.exe -ArgumentList '--silent' -Wait -PassThru
$p.ExitCode
```

In cmd, use `start /wait "" Hello-Setup-1.4.0.exe --silent` and read `%ERRORLEVEL%`. PowerShell needs the `.\` in front of a file in the current folder. See [Silent installs](/docs/guides/silent-installs.md).

## How the command line is read

A value can follow a flag after a space or be attached with an equals sign: `--dir "D:\My Apps\Hello"` and `--dir="D:\My Apps\Hello"` are the same, and every flag also works with a slash, like `/DIR=D:\Apps\Hello`. Flag names ignore case. `--with` and `--without` can be given several times and add up. Any other flag given twice keeps its last value.

A mistake is never guessed at. These all stop setup before anything is installed, with [exit code](/docs/reference/setup/exit-codes.md) `2` and a sentence that names the flag:

* an unknown flag, such as the typo `--silnet`, or a stray word
* a flag that needs a value and gets none, or gets another flag (`--dir --silent`)
* a value on a flag that takes none (`--silent=yes`)
* a `--theme` that is not `light`, `dark` or `system`, a `--style` that is not a built-in style or comes without `--preview`, and a `--wait-for` that is not a number

A terminal gets the sentence on its error output. A setup file that was double-clicked shows a message box. A service or deployment tool (session 0) gets only the exit code, because nobody could click a box there. `--help` works whatever else is on the line.

## Install flags

| Flag | Meaning |
| - | - |
| `--silent`, `/S`, `/silent`, `/quiet`, `/q`, `/VERYSILENT`, `/qn`, `/qb` | No window. See [Exit codes](/docs/reference/setup/exit-codes.md). The Inno Setup and Windows Installer spellings are accepted, so a deployment script that already uses them keeps working. |
| `--dir PATH`, `/DIR=PATH`, `/D=PATH` | Install here instead of the default folder (a first install, when `change_folder` allows it). `/D=` is NSIS's: like NSIS, it takes the rest of the command line, so an unquoted path with spaces works when `/D=` comes last. |
| `/NORESTART`, `/SP-`, `/SUPPRESSMSGBOXES`, `/NOCANCEL`, `/NCRC`, `/CLOSEAPPLICATIONS`, `/NOCLOSEAPPLICATIONS`, `/RESTARTAPPLICATIONS`, `/NORESTARTAPPLICATIONS` | Inno Setup and NSIS switches that ask for what a Bach setup does anyway: it never restarts Windows and shows no message boxes in a silent run. They are accepted and ignored, so a script that passes them doesn't fail with exit code `2`. |
| `--with a,b` | Tick these options. Comma separated. |
| `--without a,b` | Untick these options. Comma separated. |
| `--lang CODE` | The language for messages, instead of Windows' own |
| `--allow-downgrade` | Install over a newer version. Refused otherwise, with exit code `1`. |
| `--skip-requirements` | A silent install goes on although a [`[[requirements]]`](/docs/reference/config/requirements) entry (WebView2, .NET and so on) isn't detected. It stops with exit code `1` otherwise. Setup names what it passed over in the terminal and the log, and that the app may not start without them. |
| `--repair` | With `--silent`, run the setup file of the installed version with this flag: setup checks every file against the SHA-256 in its manifest, writes back the ones that are missing or changed and redoes shortcuts and registration. Nothing else in the folder and no user data is touched. A different version, or nothing installed, stops with exit code `1`. The log lists what was written. |
| `--overwrite` | A first install into a folder that already holds files of the same names as the setup file's, and no earlier install of this app, is refused with exit code `1`. The message names up to five of the files. This flag installs over them anyway. |
| `--key-file FILE` | The access key (the file's first line) for a setup file with [`[access]`](/docs/reference/config/access). The `BACH_ACCESS_KEY` environment variable does the same. Without a key a silent run exits with code `2`; with a wrong one, `1`. |
| `--log FILE` | Where the log goes. By default `%TEMP%\<app id>-setup.log`. |
| `--help`, `-h`, `/?` | Print every flag and exit |

### Option names for `--with` and `--without`

| Name | Option |
| - | - |
| `desktop-shortcut` | The desktop shortcut |
| `start-menu` | The Start menu shortcut |
| `autostart` | Start with Windows |
| `path` | Add to `PATH` |
| `auto-update` | [Automatic updates](/docs/guides/updates.md) |
| a component id | An [optional component](/docs/reference/config/components.md) |

Names are case-insensitive, and only options the install page would offer have an effect.

## Uninstall flags

Run them on the `uninstall.exe` in the install folder:

| Flag | Meaning |
| - | - |
| `--silent` | Remove without a window, in place, so the caller can wait for the exit code |
| `--delete-data` | Also delete the data folders from `[uninstall] data` |
| `--lang CODE` | The language for messages |
| `--log FILE` | Where the log goes |

With no flags, running `uninstall.exe` opens the removal window. It first copies itself to the temp folder and exits, because a running program cannot delete its own file. A machine-wide app's uninstaller asks for administrator rights first, runs elevated and removes from where it is instead.

## Update flags

Available on an installed `uninstall.exe` when the app has an [`[updates]`](/docs/reference/config/updates) section:

| Flag | Meaning |
| - | - |
| `--check-update` | Exit code `10` when a newer version is available (and print it), `0` when up to date (or when a [staged rollout](/docs/guides/updates.md#staged-rollouts) has not reached this computer yet), `1` when the feed cannot be read. Changes nothing. |
| `--channel beta`, `stable` or `show` | Follow the beta or the stable update feed from now on, or say which one this is. `beta` needs [`[updates] beta_feed`](/docs/reference/config/updates) and exits with code `1` without it. See [Beta versions](/docs/guides/updates.md#beta-versions). |
| `--check-update --json` | Print one line of JSON instead: `app`, `current`, `latest`, `available`, `downloaded`, `notes`, `size` |
| `--download-update` | Download a newer version into `%LOCALAPPDATA%\Bach\updates\<app id>` and keep it ready. Exit code `10`: ready, `0`: up to date. A cut-off download continues where it stopped. |
| `--apply-update` | Install the version that was kept ready, silently. Exit code `0`: installed, or nothing was waiting. `1`: it could not be installed yet, and stays ready. |
| `--wait-for PID` | With `--apply-update` or `--update`: wait up to ten minutes for that process (your app) to end first |
| `--launch` | With `--apply-update` or `--update --silent`: start the app again after the update |
| `--update` | Download the newer setup file (or use the one kept ready) and open its window |
| `--update --silent` | Install the newer version without a window. Exits with the setup's own code. |
| `--auto-update` | One background round: check, download, and install when the app is not running. The "Automatic updates" scheduled task runs this. |

A protected app's update runs read the key kept at install time. `--key-file FILE` or `BACH_ACCESS_KEY` give one yourself. Every update run writes `%TEMP%\<app id>-update.log`. See [Updates](/docs/guides/updates.md) for how to use them from your app.

## Preview flags

The preview flags are used by `bach preview` and in Bach's own development. They show the window with every step pretended:

| Flag | Meaning |
| - | - |
| `--preview` | Pretend every step. Nothing is installed or removed. |
| `--uninstall` | Show the removal window |
| `--theme THEME` | `system`, `light` or `dark` |
| `--lang CODE` | The language to show |
| `--style NAME` | Show another [built-in style](/docs/reference/config/style.md), in the theme it looks best in unless `--theme` says otherwise. Only with `--preview`: a setup file always wears the style it was built with, so without `--preview` it is a mistake (exit code `2`). |
| `--layout NAME` | Show another [built-in layout](/docs/reference/config/layout.md) in place of the payload's `[layout]`. Only with `--preview`, likewise. |

See [Silent installs](/docs/guides/silent-installs.md) for examples.


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