Skip to main content
By default a Bach setup file installs for the person who runs it and never asks for administrator rights. When an app has to be there for every user of a computer, set installer.scope = "machine": setup then installs into %ProgramFiles% and HKLM after a single Windows prompt. This page shows how it behaves, what moves to the computer’s side and what to watch out for.
bach.toml

What happens

Setup starts again with administrator rights before it does anything. Windows shows its prompt once, or asks for an administrator’s password, and then the whole install runs elevated. Nothing is hidden from that prompt. A setup run from an elevated terminal, or by a deployment tool that already has the rights, does not ask. The uninstaller works the same way: when Settings › Apps starts uninstall.exe, it starts itself again elevated first. An update started by the app asks when its setup file starts.

What moves

Silent installs

--silent works the same way. Run from a terminal that is not elevated, it shows Windows’ prompt, and declining it exits with code 1. Deployment tools that run setup elevated or as SYSTEM see no prompt. See Silent installs.

Things to know

  • No background updates. An update has to write to Program Files, which a signed-in user cannot do. [updates] auto must be left out or "never". The app can still use --check-update, --download-update and --update, and Windows asks when the update installs.
  • The install folder has to be inside Program Files. A machine-wide app runs, updates and uninstalls with administrator rights, so setup refuses a folder that the user’s own programs could write to, with the usual “choose another folder” message. Even inside Program Files, setup reads the folder’s access list before it writes, and again before an elevated update or removal. A folder that Users, Authenticated Users or Everyone may change, or that Administrators, SYSTEM and TrustedInstaller do not own (for example one an old installer left behind), is refused. Delete the folder or correct its permissions and try again.
  • Protected setup files need --key-file when run silently. The elevated copy is sure to get the arguments, but the BACH_ACCESS_KEY variable may not reach it.
  • Data folders belong to one account. “Also delete my data” deletes the data folders of the account that runs the uninstaller, because %APPDATA% and %LOCALAPPDATA% belong to one user.
  • Do not change scope after your first release. An app installed per user and one installed machine-wide are two installs to Windows, so an update with the other scope installs next to the old one instead of replacing it.
  • Run steps need no second prompt. Setup is elevated already, so a [[run]] step that needs administrator rights, like the Visual C++ redistributable, just runs.
  • Services and firewall rules need this scope. [[services]] and [[firewall]] install with administrator rights, so they work only with installer.scope = "machine". Drivers are not built in: a [[run]] step can start a program that installs one.

Elevate one step only

If only one program needs administrator rights, keep the install per user and mark that step:
bach.toml
Windows asks once when that step starts. See [[run]] for what an elevated step may do and why to keep it to well-known installers.

Check what you built

bach inspect on the setup file shows Installs to %ProgramFiles%\<folder> and For every user of the computer (asks for administrator rights once). bach preview opens the window without asking for administrator rights and installs nothing. See the [installer] reference, Files and locations and the safety rules.