6 Dialogs, a license, and starting the program
Goal: an installer with pages - welcome, a license the user must accept, a choice of folder, progress, finished - that offers to start Hello at the end.
6.1 The source#
LICENSE.txt and banner.bmp (a picture about 493 x 58 pixels) are next to the source.
# tutorial 06: hello.toml
format = 1
[package]
name = "Hello"
manufacturer = "Example Software"
version = "$(VERSION)"
arch = "x64"
upgrade-code = "{3F2A6C1D-8B4E-4F7A-9C2D-5E6F7A8B9C0D}"
ui = "installdir"
license = "LICENSE.txt"
[define]
VERSION = "1.4.0"
[ui]
banner = "banner.bmp"
launch = "file:Hello"
launch-args = "--first-run"
launch-checked = true
[ui-text.WelcomeText]
text = "This will install [ProductName] [ProductVersion]. Close Hello if it is running."
[ui-text.ExitText]
text = "[ProductName] is ready. Thank you for installing it."
[dir.INSTALLDIR]
path = "$(ProgramFiles)/Hello"
[file.Hello]
dir = "INSTALLDIR"
source = "dist/hello.exe"
[shortcut.StartMenu]
dir = "Programs"
name = "Hello"
target = "file:Hello"6.2 Choosing a set of pages: ui#
ui in [package] picks one of the built-in dialog sets:
ui | When installing | When run again after installation |
|---|---|---|
| (none) | Windows Installer's own small progress window only | a small window: repair or remove |
basic | progress, then finished (or an error) | repair or remove |
minimal | welcome, the license (if any), progress, finished | repair or remove |
installdir | welcome, license, install folder (Browse opens Windows' folder picker), ready, progress, finished | repair or remove |
features | as installdir, plus a tree of features and the disk space they need (chapter 8) | change, repair or remove |
A package with optional parts (chapter 8) has Change in every row but the first.
The ready page, last before Install, repeats what was chosen: the install folder, whether the program is installed for everyone on the computer or for the user alone, and - when there are features to choose - the features that will be installed (up to five by name, then how many more). Install stays refused while a disk lacks the space the installation needs.
Every set also has the pages Windows needs when something happens: "Are you sure you want to cancel?", an error message, "these programs use files that must be replaced" (files in use), and "not enough disk space". A package with dialogs still installs silently with /qn: every page only collects values that have defaults.
6.3 The license: license#
license = "LICENSE.txt" adds a license page after the welcome page. Next stays disabled until "I accept the terms of the license agreement" is ticked. The file may be:
.txtor.md- shown as plain text; Korean, other scripts and emoji are kept;.rtf- shown as it is, with its fonts and formatting (make it in WordPad or Word).
The license text is stored in the package when it is built; the user does not need the file.
6.4 The install folder#
With installdir or features, a page shows the install folder, which the user may type, and a Browse… button that opens Windows' own folder picker - the window Explorer uses, with its address bar, folder tree, search and New folder. The product's folder name is added to the folder picked, unless it already ends in it: picking D:\Apps gives D:\Apps\Hello\ (the folder box takes any other path as typed). The folder becomes INSTALLDIR, and every dir built on INSTALLDIR moves with it. Where the picker cannot be shown, the page opens a browse page of its own instead. To let the user change another dir, name it: install-dir = "AppDir" in [ui]. From the command line the folder is given as a property:
msiexec /i hello.msi INSTALLDIR="D:\Tools\Hello"6.5 A picture at the top: banner#
banner = "banner.bmp" puts a picture in the strip at the top of every inner page (Windows Installer draws a BMP; about 493 x 58 pixels). Without it the strip is plain white.
6.6 Your own words: [ui-text.ID]#
Every text on the built-in pages has an ID; [ui-text.ID] replaces one. The IDs are listed in the Reference part (Dialogs); WelcomeText and ExitText are the sentences on the first and the last page. Texts are formatted strings: [ProductName], [ProductVersion] and [Manufacturer] are replaced, and a literal square bracket is written [\[]. In a button's text, & marks the letter that works with Alt: &Next is Alt+N.
6.7 Starting the program at the end: launch#
launch = "file:Hello" puts a tick box "Launch Hello" on the finished page (ticked, unless launch-checked = false); launch-args are the program's arguments. If it is ticked, Finish starts Hello - with the rights of the user who ran the installer, not the installer's administrator rights - after a first installation or an upgrade, but not after a repair or a removal, and never in a silent installation.
6.8 Seeing what is being done: details#
While the installation runs, the progress page shows more than the bar: a box under it fills with what is being done, as it is done.
Copying new files
Copy file: C:\Program Files\Hello\hello.exe
Copy file: C:\Program Files\Hello\readme.txt
Creating shortcuts
Create shortcut: C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Hello
Writing system registry values
Write registry value: HKLM\Software\Example\Hello\VersionA removal and a repair show theirs the same way, and a failed installation shows what it takes back. Tick Show the full log under the box and it holds the log file's own lines instead - everything Windows Installer writes about the run. When the run ends, the finished page (and the page for a cancelled or failed installation) keeps those lines in a box of its own, to scroll through before deciding whether to save the log. details = false in [ui] leaves both boxes out.

Figure 6.1 — The progress page with its details box
6.9 Saving the log: save-log#
The finished page - and the pages for a cancelled or failed installation - have a Save log… button at the bottom left. It opens the usual Save As window and saves a copy of what Windows Installer wrote about this run: every file, registry value and action, and on a failed page the error that stopped it. That is the file to send when someone asks why an installation went wrong. For it, the package asks Windows Installer to keep a log of every run (MsiLogging), in the user's temporary folder, unless msiexec /l names one. save-log = false in [ui] leaves the button out, and with it the logging.
6.10 Try it#
Double-click hello.msi: welcome (with your text and the banner), the license (Next is grey until you tick the box), the install folder, ready, progress, finished with "Launch Hello" ticked. Run it again after installing: a page offers Repair and Remove. Remove does not remove at once: a second page says what will go, and its Remove button does it (Back, the default, returns).
![Welcome, with the text of [ui-text.WelcomeText]](img/ch06-welcome.png)
Figure 6.2 — Welcome, with the text of [ui-text.WelcomeText]

Figure 6.3 — The license: Next stays grey until the box is ticked

Figure 6.4 — The install folder, changeable

Figure 6.5 — Ready to install

Figure 6.6 — Finished, with "Launch Hello" ticked

Figure 6.7 — Run again after installing: Repair or Remove
6.11 What happened inside#
A package with dialogs carries them as tables - Dialog, Control, ControlEvent and more - that describe every window, button and text box with its position and what happens when it is pressed. rubrapack writes them from its built-in sets:
C:\work\hello> rubrapack inspect hello.msi Dialog
...
RpBrowseDlg RpCancelDlg RpErrorDlg RpExitDlg RpFatalDlg RpInstallDirDlg RpLicenseDlg
RpMaintenanceDlg RpOutOfDiskDlg RpProgressDlg RpReadyDlg RpUserExitDlg RpWelcomeDlg FilesInUse(Here only the first column is shown.) The InstallUISequence table says when a page appears:
RpWelcomeDlg NOT Installed 1230
RpMaintenanceDlg Installed AND NOT RESUME AND NOT Preselected 1240
RpProgressDlg 1280
RpExitDlg -1
RpUserExitDlg -2
RpFatalDlg -3The middle column is a condition: the welcome page only when the product is not installed yet, the maintenance page when it is. The negative numbers are special: the page shown at the end after success (-1), after the user cancelled (-2), after a failure (-3). Chapter 9 uses conditions of your own.