Skip to content

Setup Exe

Carlos Hernandez edited this page Jul 14, 2026 · 5 revisions

setup.exe

embala's setup backend produces a graphical Windows installer — a wizard with mode, welcome, license, directory, components, progress, and finish pages. The honest part up front: embala build never compiles anything to make it. embala ships a prebuilt installer runtime (the "stub") and, at build time, only appends your payload, scripts, and metadata to it as bytes. The same config built twice produces byte-identical output.

What that buys you: no NSIS, no WiX, no toolchain, no network in the build — a setup.exe is a pure function of (stub, your files, your config). What it costs you is covered honestly in Limitations.

For the full config field tables see Configuration-Reference; for signing and the SmartScreen/publisher reality see Code-Signing; for the Windows Installer alternative see MSI. New to embala? Start at Getting-Started.

What you get

A single <name>-<version>-<arch>-setup.exe. Double-clicked, it runs the wizard. Run from a shell with /S, it installs headless. The pages it can show, in wizard order:

Page Shown when Does
mode install-mode = user-choice user picks per-user vs per-machine
welcome always intro screen
license a license file is set shows the text; must be accepted to proceed
directory always pick the install directory
components components are declared user selects optional component sets
progress always (implicit) live progress as files land
finish always optionally run the app, offers links

A fixture installer (per-user, license + one optional component) captured on Windows 11:

Welcome page License page
Directory page Components page
Progress page Finish page

The installer's own window, setup.exe's Explorer icon, and its version metadata are per-package — see Branding. The installed app's icon — on its shortcuts and in Add/Remove Programs — comes from your main-executable, independently of the installer's own icon.

Install modes

The manifest carries a default mode; a /mode= flag overrides it at install time. The resolved mode decides three things together: where files land, whether UAC elevation is required, and which registry hive the Add/Remove Programs (ARP) entry and any registry writes go into.

Mode Install directory Elevation Registry hive
per-user (default) %LOCALAPPDATA%\Programs\<name> none HKCU
per-machine %ProgramFiles%\<name> UAC-elevated relaunch HKLM
user-choice user picks one of the above per user's choice follows the choice

Details that matter:

  • per-user is the default and needs no UAC. It is the safe path for unmanaged machines.
  • per-machine triggers a UAC prompt. When the mode resolves to per-machine and the process is not already elevated, the installer relaunches itself elevated (re-appending /mode=per-machine so the child does not re-prompt) and propagates the child's exit code.
  • user-choice shows the mode page in the interactive wizard. In headless mode (/S) with no /mode= flag, it resolves to per-user — the no-elevation default, never a silent UAC surprise.
  • Shortcuts follow the hive. A per-machine install writes to HKLM and the all-users Start Menu; a per-user install writes to HKCU and the current user's Start Menu. The [setup].shortcuts location (start-menu default or desktop) is independent of this.

End-user CLI flags

The installer accepts NSIS-compatible flags. Unknown flags are ignored by design (so forward-compatible flags never break an install) — with one exception: a malformed /mode= value is a hard error, because a misread mode would install to the wrong hive.

Flag Effect
/S Silent/headless: no window, console reporting only, auto-accepts the license
/D=<dir> Override the install directory and lock it — the directory page cannot re-point it
/mode=per-user | /mode=per-machine Override the packaged default mode
/components=<ids> Comma-separated component ids to install (only meaningful when a components page exists)
/options=<ids> Uninstall-time only (uninstall.exe): comma-separated uninstall-option ids to pre-select, skipping the confirm dialog. Parsed but ignored by setup.exe at install time

Notes:

  • /S is case-insensitive (/s works too).
  • /D= takes the unquoted remainder of the token — a path with spaces must be quoted by the caller so it stays one argument. An empty /D= is dropped.
  • /mode= accepts only the two concrete modes. user-choice is not a CLI value — you either let the wizard ask, or pin a concrete mode.
  • /components= splits on commas and ignores empty entries; it selects the component set for a components-bearing installer. It has no effect on an installer that declares no components.
  • /options= is the uninstaller's counterpart to /components= — it names which uninstall options to apply, splits on commas, and ignores ids that weren't declared. It is accepted on setup.exe too (so the flag never errors) but has no effect at install time.

Example — a silent per-machine install to a fixed directory:

setup.exe /S /mode=per-machine /D="C:\Program Files\Hello"

Declarative config: the [setup] section

The 80% path is declarative TOML — embala lowers it to the installer script for you. The fields:

Field Required Meaning
arch yes x86_64 or aarch64 (selects the embedded stub)
files yes [{src, dest}] payload; src is relative to the config dir
main-executable no shortcut target + ARP DisplayIcon, relative to the install dir
install-mode no (default per-user) per-user | per-machine | user-choice
license no path to a license text file (relative to the config dir)
components no [{id, label, description?, default?, files}] optional feature sets
shortcuts no [{name, target, args?, icon?, location?}] (location: start-menu default | desktop)
script no escape hatch: path to a raw installer script
uninstall-script no path to a raw uninstall script

The full tables (validation rules, every field) live in Configuration-Reference. A worked example with a component and a shortcut:

[package]
name = "hello"
display-name = "Hello"
version = "1.2.0"
identifier = "com.example.hello"
publisher = "Example Inc."
description = "A friendly greeter."

[setup]
arch = "x86_64"
install-mode = "user-choice"
main-executable = "hello.exe"
license = "LICENSE.txt"
files = [
  { src = "dist/hello.exe", dest = "hello.exe" },
]
components = [
  { id = "docs", label = "Documentation", default = true, files = [
    { src = "dist/README.txt", dest = "readme.txt" },
  ] },
]
shortcuts = [
  { name = "Hello", target = "hello.exe", location = "desktop" },
]

embala validates this at parse time: unknown arch is rejected, every src must exist, main-executable and every shortcut target must be among the installed dests, component ids must be unique, and a license path must exist. A raw script cannot be combined with components, shortcuts, or main-executable — the raw script owns that behavior, so embala surfaces the conflict rather than silently ignoring the sugar.

Uninstall

Every install writes an uninstaller into the install directory:

File Purpose
uninstall.exe the runtime with no payload; run it to uninstall
install.log every mutating action, in order, for the reversal
manifest.json product context so a custom uninstall script can rebuild embala.package
uninstall.lua present only if you shipped a custom uninstall script

uninstall.exe is registered in Add/Remove Programs. Running it:

  1. Interactively (no /S), shows one confirm dialog before anything mutates. Its title is Uninstall <display-name>, its body names the install directory (This will remove <display-name> from: <dir>), and it renders one checkbox per declared uninstall option (pre-ticked per each option's default), with Uninstall and Cancel buttons. Cancel — the button, the window's [X], or Esc — exits nonzero with nothing removed.
  2. Runs the optional uninstall.lua (best-effort custom teardown), which can read the confirmed option choices via embala.ui.selected(id) (see Lua-Scripting), then
  3. Replays install.log in strict LIFO order through the shared reversal engine — the last thing installed is the first thing removed. This removes files, shortcuts, registry and environment writes, empty directories, and the ARP entry, idempotently.
  4. Self-deletes uninstall.exe and the install directory.

/S skips the dialog and runs headless — options resolve from /options= if given, otherwise from the declared defaults. Selection precedence, highest first: /options=id1,id2 (unknown ids ignored) > confirm-dialog ticks > declared defaults.

Per-machine uninstalls elevate. If the install resolved to per-machine and uninstall.exe isn't already elevated, it shows the confirm dialog first, then relaunches itself elevated (via UAC) with /S /options=<selected> so the elevated child neither re-prompts nor re-shows the dialog, and propagates its exit code. A per-user uninstall runs in-process with no UAC.

Uninstall options

[setup].uninstall-options = [{ id, label, default? }] declares the checkboxes the confirm dialog shows — a "delete all app data" toggle is the canonical case. They travel to the uninstaller through the manifest.json sidecar and are readable from uninstall.lua with embala.ui.selected(id). They work with both the declarative and the raw-script config (they concern uninstall, not install lowering). See Configuration-Reference for the field rules and Lua-Scripting for reading them. A missing or unparseable manifest.json degrades to a confirm dialog with no checkboxes — the confirm still shows.

User data is preserved. Directory removal only removes empty directories, so anything your app or user created inside the install tree after install (logs, config, saved data) keeps the directory alive and survives the uninstall. The log replay reverses what the install did, not what happened afterward.

Scripting

The declarative [setup] section is sugar over a native embala.* installer API. For full control — conditional logic, custom pages, running commands during install — you can supply a raw Lua script instead via script (and uninstall-script). The declarative fields lower to exactly this API, so there are no parallel engines; the raw script is the same substrate with the training wheels off. See Lua-Scripting for the API surface and page kinds.

Branding

setup.exe is branded per-package. At embala build time — before the overlay is appended — embala patches the prebuilt stub's PE resources, the same way NSIS brands its own stub (never compiling anything, and the build stays byte-reproducible):

Source Patches Shows up as
[setup].icon (else [package].icon) the stub's main icon (PNG or ICO) setup.exe's Explorer icon, the wizard title bar/taskbar, and the uninstall confirm window
[setup].banner a named bitmap resource (BMP, validated BM at config load) the left column of the wizard's welcome and finish pages (164×314 logical px, DPI-scaled); pages lay their text beside it
[package] metadata a VERSIONINFO resource (always written) Explorer → Properties → Details: ProductName, CompanyName, FileDescription, and File/Product version

VERSIONINFO's numeric FileVersion/ProductVersion is derived from the leading major[.minor[.patch]] digits of [package].version (a fourth component is always 0; an unparseable component collapses to 0); the string fields carry the full version string plus LegalCopyright when [package].copyright is set.

uninstall.exe is a prefix copy of the running stub, so it inherits the same icon and version info with no extra work. If no banner is set, the wizard renders exactly its unbranded layout — no empty gap. The signing implications (sign the patched stub, not the bare one) are in Code-Signing.

Limitations

These are scope decisions, not defects:

  • DPI changes mid-session are not re-scaled. The wizard picks up the display scaling at launch; moving the window to a monitor with a different DPI during the install will not re-lay-out the pages.
  • aarch64 (ARM64 Windows) is supported and shipped, but verification differs by arch: x86_64 is verified end-to-end on real Windows, while the aarch64 stub is cross-compile-tested only — not yet verified on ARM64 hardware.
  • Signing is separate and honest about what it changes. embala can embed a pre-signed uninstall stub so the installer lays down a signed uninstall.exe, but that is the one signing nuance specific to setup.exe — the full mechanics, and the reality that signing only clears the unknown-publisher prompt for certs the target already trusts, are in Code-Signing.

Clone this wiki locally