[[run]] runs a program from your own files while setup installs or removes the app. Use it for what copying files cannot do, like a runtime’s own installer or a driver. Add the program under [files] source so it is packaged.
bach.toml
How it runs
- Steps run in the order listed, as the user, in the program’s own folder. Setup waits for each one.
- A program that asks for administrator rights fails to start, and that is reported like any other failure, unless the step says
elevated = true. Setup then starts that program through Windows’ administrator prompt and the rest of the install stays unelevated. Bach asks for administrator rights only when you tell it to, here or withinstaller.scope = "machine". - A step that runs longer than 15 minutes is ended and counts as failed.
- A failed install step stops the install with a readable sentence, and “Try again” runs it all again. Set
ignore_errors = trueto go on instead. - A step with
when = "uninstall"runs while the app’s files are still there, and a failure never stops the removal. An app must always be removable. - Every run, with its exit code, is in
%TEMP%\<app id>-setup.log.bach inspectlists steps asRuns.
Elevated steps
Some programs only work with administrator rights, like the Visual C++ redistributable’s own installer:bach.toml
elevated for well-known installers, and sign them, not for anything else. bach check warns about that combination. Right before Windows is asked for administrator rights, setup checks the file against the size and SHA-256 recorded when the setup file was built, and does not start a program that was swapped since.
A step that runs past timeout_minutes is ended together with everything it started, with one exception: an elevated step in a setup that is not elevated itself (a per-user install). Windows does not let a program without administrator rights end one that has them, so setup only stops waiting, says so in the log, and the program may keep running until it ends or somebody closes it in Task Manager. The exit code of an elevated step is read the same way as for any other step. If the user declines Windows’ prompt, the step fails and the log says so.
The texts step_running and error_run can be replaced under [text].