Skip to main content
[[services]] installs Windows services: an agent, a sync engine, a local server. A service runs without anyone signed in and starts with Windows. A service is installed with administrator rights, so [[services]] needs installer.scope = "machine". In a per-user config, bach check stops with a sentence that says so.
bach.toml

What setup does

1

First install

Creates each service, then starts it when start is auto or delayed. A service that doesn’t reach the running state in 30 seconds fails the install, and the install is undone: the services setup made are deleted again.
2

Update

A running service holds its program, so setup stops it (up to 30 seconds) before the files are swapped, brings its definition up to date and starts it again, if it was running or start says so. A service the new version no longer lists is stopped and deleted. If anything fails after the files were placed, the earlier version’s files and services come back.
3

Removal

Stops each service, deletes it, then deletes the files. A service that won’t stop or delete is logged; removal itself never stops for it.

What to know

  • Setup only changes a service it can prove is its own: one whose program is in the install folder. If a service with that name already exists and starts something else, the install stops with ” couldn’t be set up (exit code exists)” and the log names the program. Pick a name that is yours.
  • A setup file with [[services]] can’t be an MSI: bach build --msi stops and says so.
  • bach inspect lists each service as Service, and bach diff shows one that was added, removed or changed.
  • Pair it with [[firewall]] when the service listens for connections.
  • --preview pretends, like every other step.