> ## 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 for IT tools and scripts

> Install and remove Bach setup files without a window using --silent or /S, with --dir, --with, --without, --lang, --log and exit codes for automation.

Every setup file also installs without a window, for IT tools and scripts. You do not configure anything for this in `bach.toml`: the flags are part of the runtime every setup file is built from.

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

A setup file is a windowed program, so a shell does not wait for it. Running `.\Hello-Setup-1.4.0.exe --silent` directly installs but returns at once, without an exit code. `Start-Process -Wait -PassThru` waits and gives you the exit code. PowerShell also needs the `.\` in front of a file in the current folder.

In cmd, use `start /wait` and read the exit code from `%ERRORLEVEL%`:

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

## Flags

| Flag | Meaning |
| - | - |
| `--silent` (also `/S`, `/silent`, `/quiet`, `/q`) | No window. Exit code `0` when done, `1` when it failed (the reason is printed in a terminal), `2` for a command-line mistake. |
| `--dir PATH` | Install here instead of the default folder (a first install, when `change_folder` allows it). |
| `--with a,b` / `--without a,b` | Tick or untick options: `desktop-shortcut`, `start-menu`, `autostart`, `path`, and component ids. Only options the install page would offer. |
| `--lang CODE` | The language for messages, instead of Windows' own. |
| `--allow-downgrade` | Install over a newer version. Refused otherwise, with exit code `1`. |
| `--overwrite` | Install a first time into a folder that already holds files of the same names. Refused otherwise, with exit code `1`, naming up to five of the files. |
| `--log FILE` | Where the log goes. By default every run writes `%TEMP%\<app id>-setup.log`. |

Every flag is one text in the argument list. A path with spaces gets its own quotes:

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

## What a silent run does for the user

* It accepts the license on the user's behalf.
* It stops when a [requirement](/docs/guides/requirements.md) is missing, with exit code `1`.
* It applies the same checks as the window: free space, the app not running and the archive checksum.

## Machine-wide setup files

A setup file with `installer.scope = "machine"` needs administrator rights, so a silent run started without them shows Windows' administrator prompt first and ends with code `1` if it is declined. A deployment tool that runs setup elevated or as SYSTEM sees no prompt. See [machine-wide installs](/docs/guides/machine-wide-installs.md).

## Silent uninstall

Settings › Apps runs `uninstall.exe --silent` for a quiet removal. You can run it yourself:

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

`%LOCALAPPDATA%` is cmd syntax. PowerShell writes it `$env:LOCALAPPDATA`.

Add `--delete-data` to delete the user's data folders too. A silent removal works in place, so whoever started it can wait for its exit code.

## Exit codes

| Code | Meaning |
| - | - |
| `0` | Done |
| `1` | Failed. The reason is printed in a terminal and written to the log. |
| `2` | A command-line mistake |
| `10` | From `uninstall.exe --check-update` only: a newer version is available |

## Logs

Every run, silent or not, writes `%TEMP%\<app id>-setup.log`, or the file you pass with `--log`. It lists the steps and, when something fails, why. Logging never holds setup up. Read it when something fails instead of guessing.

## winget

Because setup files accept `--silent` (and install per user unless `installer.scope = "machine"`), they work with the Windows Package Manager. See [List your app in winget](/docs/guides/winget.md).


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