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

# [[run]]: run a program during setup

> Every [[run]] setting, when steps run, exit codes and timeouts, elevated steps, and what happens when a program fails during install or removal.

`[[run]]` runs one of your packaged programs during install or removal, for things copying files can't do. Walkthrough: [Run programs during setup](/docs/guides/run-programs.md).

```toml bach.toml theme={"theme":{"light":"github-light","dark":"github-dark"}}
[[run]]
name = "Visual C++ runtime"
file = "redist/vc_redist.x64.exe"
arguments = "/install /quiet /norestart"
when = "first_install"
success_codes = [0, 1638, 3010]
elevated = true
```

| Setting | Default | Meaning |
| - | - | - |
| `file` | required | A packaged `.exe`, relative to `files.source`. Nothing else can be run, and no command shell is used. |
| `name` | file name without `.exe` | Shown as **Setting up** {name}, the same in every language. Up to 100 characters. |
| `arguments` | none | Passed exactly as written, up to 2000 characters |
| `when` | `"install"` | `"install"` (install, update and repair), `"first_install"`, or `"uninstall"` (before files are removed) |
| `success_codes` | `[0]` | Exit codes that count as success. `0` always does. |
| `ignore_errors` | `false` | Continue when it fails. Not allowed with `when = "uninstall"`, which never stops anyway. |
| `component` | the file's component | Run only when this component is installed |
| `elevated` | `false` | Run with administrator rights. Windows asks once; not at all if setup already has them. |
| `timeout_minutes` | `15` | 1 to 120. The program and everything it started is ended after this. |

## Behavior

* Steps run one at a time, in the order listed, as the current user, in the program's own folder.
* Their output goes into the setup log (the last 8 KB of it), with the exit code.
* A failed step during install stops it with {name} **couldn't be set up (exit code N)**, and the previous state is restored. What the program itself already changed isn't undone.
* A failed step during removal never stops the removal.
* A program that needs administrator rights but runs without `elevated = true` fails to start.

## Elevated steps

In a per-user install, the install folder can be changed by the user's other programs. Right before asking for rights, setup compares the program with its recorded checksum. Still, only elevate well-known, signed installers; `bach check` warns about elevated steps in per-user installs.

An elevated step in a per-user setup can't be ended on timeout, because Windows doesn't let a normal program end an elevated one. Setup stops waiting and says so in the log. Declining the Windows prompt fails the step.

## Related

`bach inspect` lists steps as `Runs`. The texts `step_running` and `error_run` can be [changed](/docs/reference/config/text.md). For the Mac build, use [`[[macos.run]]`](/docs/reference/config/macos).


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