Once the actual installation process begins, this is the order in which the various installation tasks are performed:
- If CloseApplications was set to yes, Setup closes applications using files that need to be updated.
- [InstallDelete] is processed.
- The entries in [UninstallDelete] are stored in the uninstall log (which, at this stage, is stored in memory).
- The application directory is created, if necessary.
- [Dirs] is processed.
- A filename for the uninstall log is reserved, if necessary.
- [Files] is processed. (File registration does not happen yet.)
- [Icons] is processed.
- [INI] is processed.
- [Registry] is processed.
- Files that needed to be registered are now registered, unless the system needs to be restarted, in which case no files are registered until the system is restarted.
- The Add/Remove Programs entry for the program is created, if necessary.
- The entries in [UninstallRun] are stored in the uninstall log.
- The uninstaller EXE and log are finalized and saved to disk. After this is done, the user is forbidden from cancelling the install, and any subsequent errors will not cause what was installed before to be rolled back.
- [Run] is processed, except for entries with the postinstall flag, which get processed after the Setup Completed wizard page is shown.
- If RestartApplications was set to yes, Setup restarts closed applications which support being restarted.
- If ChangesAssociations was set to yes or to a scripted boolean expression evaluating to True, file associations are refreshed now.
- If ChangesEnvironment was set to yes or to a scripted boolean expression evaluating to True, other applications are notified at this point.
All entries are processed by the installer in the order they appear in a section.
You can see the order yourself by loading a script into the Compiler IDE and pressing F7 (Step Into) repeatedly: each time Setup or Uninstall is about to process an entry the IDE will pause Setup or Uninstall and show you the entry.
Changes are undone by the uninstaller in the opposite order in which the installer made them. This is because the uninstall log is parsed from end to beginning.
In this example:
[INI]
Filename: "{win}\MYPROG.INI"; Section: "InstallSettings"; Flags: uninsdeletesectionifempty
Filename: "{win}\MYPROG.INI"; Section: "InstallSettings"; Key: "InstallPath"; String: "{app}"; Flags: uninsdeleteentry
the installer will first record the data for first entry's uninsdeletesectionifempty flag in the uninstall log, create the key of the second entry, and then record the data for the uninsdeleteentry flag in the uninstall log. When the program is uninstalled, the uninstaller will first process the uninsdeleteentry flag, deleting the entry, and then the uninsdeletesectionifempty flag, deleting the section.
Note that the uninstaller processes [UninstallRun] and [UninstallDelete] entries in the same order they appear in the script (not in reverse order).