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

# Silent installs and uninstalls

> Install or remove a Bach app without a window, for scripts and IT tools: choose options and folders, read exit codes and logs, and wait correctly.

Every Bach setup file can install without showing a window, which IT tools and scripts need. There's nothing to configure in `bach.toml`; this is built into every setup file. This page shows how to run it and read the result.

## Install silently

A setup file is a windows program, so a terminal doesn't wait for it by default. In PowerShell, use `Start-Process` with `-Wait`:

```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 Command Prompt:

```bat theme={"theme":{"light":"github-light","dark":"github-dark"}}
start /wait "" Hello-Setup-1.4.0.exe --silent
echo %ERRORLEVEL%
```

`/S` works too, as do common switches from other installers such as `/VERYSILENT` and `/qn`.

## Choose where and what

```powershell theme={"theme":{"light":"github-light","dark":"github-dark"}}
Start-Process ".\Hello-Setup-1.4.0.exe" -Wait -PassThru -ArgumentList '--silent', '--dir', '"D:\Apps\Hello"', '--with', 'path,samples', '--without', 'desktop-shortcut'
```

* `--dir` sets the folder for a first install. Updates stay where the app already is.
* `--with` and `--without` tick or untick options: `desktop-shortcut`, `start-menu`, `autostart`, `path`, `auto-update`, and the ids of your components. Only options your window would offer can be changed.
* A path with spaces needs its own quotes inside the argument, as shown.

[Setup file options](/docs/reference/setup/command-line.md) lists every flag.

## What a silent install does differently

* It accepts your license for the user.
* It doesn't ask questions. Where the window would ask, it fails with exit code 1 instead: a newer version already installed (`--allow-downgrade`), files in the way (`--overwrite`), a missing requirement (`--skip-requirements`), or the app still running.
* Apps with an access key need `--key-file <file>` or the `BACH_ACCESS_KEY` environment variable.

## Exit codes

| Code | Meaning |
| - | - |
| 0 | Done |
| 1 | Failed. The reason is printed and logged. |
| 2 | A mistake in the command line, or a missing access key |

## Logs

Each run writes `%TEMP%\<app id>-setup.log`. Use `--log <file>` to choose another place. When something fails, read the log; it says which step failed and why.

## Uninstall silently

```powershell theme={"theme":{"light":"github-light","dark":"github-dark"}}
$uninstall = "$env:LOCALAPPDATA\Programs\Hello\uninstall.exe"
Start-Process $uninstall -ArgumentList '--silent' -Wait -PassThru
```

Add `--delete-data` to also delete the data folders listed in [`[uninstall]`](/docs/reference/config/uninstall). Settings › Apps uses `uninstall.exe --silent` for its quiet removal.

## Apps installed for all users

A setup file with `installer.scope = "machine"` needs administrator rights. Run it from an elevated terminal or through a deployment tool that runs as administrator or SYSTEM. Otherwise Windows shows its permission prompt, and declining it ends with exit code 1.

Deploying across a company? See [MSI, Intune and Group Policy](/docs/guides/msi.md).


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