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

# [signing]: sign your setup files

> Reference for [signing] in bach.toml: name the program that signs your setup files. Signing is optional and only runs with bach build --sign or BACH_SIGN=1.

`[signing]` tells Bach which program signs your setup files, so `bach build --sign` can do it instead of you running a signing tool by hand. Without this section nothing is signed, and a plain `bach build` never signs.

```toml bach.toml theme={"theme":{"light":"github-light","dark":"github-dark"}}
[signing]
program = "signtool"      # default
arguments = 'sign /fd SHA256 /tr http://timestamp.digicert.com /td SHA256 /a'
```

| Setting | Default | Meaning |
| - | - | - |
| `program` | `signtool` | The signing program, started without a shell. `signtool` is part of the Windows SDK and is rarely on `PATH`. When it is not, Bach uses the newest one in `C:\Program Files (x86)\Windows Kits\10\bin` and says which. Give a full path to use another program. |
| `arguments` | required | Its arguments, split like a command line. For `signtool` they start with the word `sign`, and Bach refuses them otherwise. The setup file is added last. Write `{file}` to put it somewhere else. `{env:NAME}` is replaced by an environment variable, so secrets stay out of `bach.toml`. The build fails when the variable is not set. |

## When it runs

Signing runs only when you ask for it:

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
bach build --sign                          # build and sign
$env:BACH_SIGN = "1"; bach build           # the same, for CI (PowerShell; bash: BACH_SIGN=1 bach build)
bach sign dist/Hello-Setup-1.4.0.exe       # sign a file you built earlier
```

This is on purpose. A `bach.toml` that came from somewhere else can name any program, so building it must not run that program behind your back. Without `--sign`, a build with `[signing]` says so and leaves the files unsigned. `--sign` without a `[signing]` section is an error.

With `--sign`, Bach signs every setup file it writes (the offline installer, the online installer and an [update patch](/docs/guides/updates.md#update-patches)) before it writes the update feed, so the feed already carries the signed file's SHA-256.

## What Bach prints and checks

Bach prints the command before it runs it. `{env:NAME}` is shown as written, never as its value, so a log does not hold your secrets. A signer that fails fails the build with its exit code. A program that cannot be started is reported with its name.

With this section, `bach check` and `bach build` also warn when programs or libraries inside the setup file are not signed, for example `1 of the 2 programs and libraries in the setup file aren't signed (helper.exe)`. Signing the setup file does not sign them, and Smart App Control can block an unsigned program once it is installed. Sign them in your own build, before Bach packs them.

The installed `uninstall.exe` stays unsigned: it is written on the user's computer from the signed setup file, and a signature only covers the exact file it was made for. See [Signing](/docs/guides/signing.md).

```toml bach.toml theme={"theme":{"light":"github-light","dark":"github-dark"}}
# Cloud signers work the same way; keep the secrets in the environment.
[signing]
program = "AzureSignTool"
arguments = 'sign --azure-key-vault-url {env:KV_URL} --azure-key-vault-certificate {env:KV_CERT} -tr http://timestamp.digicert.com'
```

> [!NOTE]
>
> `bach doctor` says whether `[signing]` is set. The signer has to exist on the machine that builds. On macOS or Linux, use a signer that runs there, for example `osslsigncode`.


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