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

# [[registry]]: write registry values

> Reference for [[registry]] in bach.toml: write registry values below Software and remove them only while they still hold the value setup wrote.

`[[registry]]` writes registry values when the app is installed, for apps that read their install folder or a setting from the registry. Each section is one value. The values go to `HKCU` for a per-user install and to `HKLM` for a [machine-wide install](/docs/guides/machine-wide-installs.md).

```toml bach.toml theme={"theme":{"light":"github-light","dark":"github-dark"}}
[[registry]]
key = 'Software\Hello'          # below the hive, starting with Software\
name = "InstallPath"            # leave out for the key's default value
type = "string"                 # "string" (default), "expand" or "dword"
value = '{app}'                 # {app} is the install folder

[[registry]]
key = 'Software\Hello'
name = "FirstRun"
type = "dword"
value = 1
```

| Setting | Default | Meaning |
| - | - | - |
| `key` | required | The key, starting with `Software\`. Use single quotes so the backslashes stay as they are. |
| `name` | the key's default value | The value's name. |
| `type` | `"string"` | `"string"`, `"expand"` (text with `%VARIABLES%` that Windows fills in when it is read) or `"dword"` (a whole number from 0 to 4294967295). |
| `value` | required | The data. Text for `string` and `expand`, a number for `dword`. `{app}` in text stands for the install folder. |
| `view` | `"64"` | The registry view on a 64-bit Windows: `"64"`, `"32"` (what a 32-bit program sees) or `"both"`. See [32-bit programs](#32-bit-programs). |

## 32-bit programs

A 32-bit program that reads `HKLM\Software\Vendor` is sent by Windows to `HKLM\Software\WOW6432Node\Vendor`. A machine-wide app (`installer.scope = "machine"`) whose program is 32-bit therefore needs `view = "32"` on the values it reads, or `"both"` when it ships 32-bit and 64-bit programs. Writing, updating and removing use the same view, and `"both"` handles both. You cannot name `WOW6432Node` yourself, because that key is refused. `HKCU\Software` is not redirected, so the setting rarely matters in a per-user install.

```toml bach.toml theme={"theme":{"light":"github-light","dark":"github-dark"}}
[[registry]]
key = 'Software\Hello'
name = "InstallPath"
value = '{app}'
view = "32"
```

`bach check` and `bach build` warn when the install is machine-wide, `app.executable` is a 32-bit program (its PE header says x86) and a `[[registry]]` value leaves `view` out.

## What setup does

* An update writes the values again and removes the ones the new version no longer lists.
* Removing the app deletes a value only while it still holds exactly what setup wrote. A value that the user or the app changed since stays. Keys that end up empty are removed too, but never `Software` itself.
* Keys that belong to Windows, other programs or Bach are refused: `Software\Classes`, `Software\Policies`, `Software\Wow6432Node`, `Software\Bach`, and every key of the vendors `Microsoft`, `Google`, `Mozilla`, `Mozillaplugins`, `Chromium`, `RegisteredApplications`, `Clients` and `ODBC`. Those hold Office trusted locations, Defender exclusions, certificates, browser extension hooks and the like. `bach check` also warns when the key is not below a folder named after `app.publisher`, `app.name` or `app.id`, which usually means a typo. Use [`[[protocols]]` and `[[file_types]]`](/docs/reference/config/protocols-and-file-types) and [`[[context_menu]]`](/docs/reference/config/context-menu) for what those keys are for.
* A value can be at most 4096 characters, and the same key and name can be set only once.
* `bach inspect` lists each value as `Registry`.


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