Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Languages / Pascal

Inno Setup Tasks Demystified

5.00/5 (7 votes)
18 Oct 2023CPOL 6.5K   114  
Make installations simpler with Inno Setup [Tasks]
Instead of using complicated setups with Custom Pages, installations can be made simpler with Inno Setup [Tasks].

Introduction

For a long time, the usefulness of Inno Setup [Tasks] eluded me, and I used custom pages for more complicated setup scenarios.

Recently, I decided to give [Tasks] a try, and found that it could make some installation scenarios a lot simpler.

Image 1

Image 2

Using the Code

In the code below, a minimal example is shown with some harmless dummy apps. The code should work with Inno Setup v5 or higher. Also, the code for the dummy apps is not important here, but for those interested, I have included the VS2022 code.

When the user chooses the Client option, the Task page is not shown. When the user chooses the Server option, the Task page is shown and when the Postgres option is checked, Postgres will be "installed" before the Server app.

Pascal
;
; Test [Tasks] for Inno Setup
; Simulates a simple Client or Server installation using dummy .exe files.
;
#define MyAppName "Tasks_Test"
#define MyAppVersion "1.0"
#define MyAppPublisher "RickZeeland"

[Setup]
; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{CEB74C97-297E-49DA-AD56-CB816A92E20B}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
DefaultDirName={pf64}\{#MyAppName}
DefaultGroupName={#MyAppName}
; Uncomment the following line to run in non administrative install mode (install for current user only.)
;PrivilegesRequired=lowest
OutputBaseFilename=Tasks_Test
Compression=lzma
SolidCompression=yes
WizardStyle=modern
ArchitecturesAllowed=x64
; "ArchitecturesInstallIn64BitMode=x64" requests that the install be
; done in "64-bit mode" on x64, meaning it should use the native
; 64-bit Program Files directory and the 64-bit view of the registry.
ArchitecturesInstallIn64BitMode=x64
; Do not ask for PC restart.
RestartIfNeededByRun=no

[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"

[Types]
; Prevent showing the Types ComboBox
Name: "custom"; Description: "Custom installation"; Flags: iscustom

[Components]
Name: "client"; Description: "Client"; Flags: exclusive
Name: "server"; Description: "Server"; Flags: exclusive

[Tasks]
; The postgres Task page is only shown when server is selected
Name: "postgres"; Description: "PostgreSQL installation";  Components: server

[Files]
Source: "ClientDummy.exe"; DestDir: "{app}"; Components: client; Flags: ignoreversion
Source: "ServerDummy.exe"; DestDir: "{app}"; Components: server; Flags: ignoreversion
; Postgres dummy is only installed when server is selected and task postgres is checked
Source: "PostgresDummy.exe"; DestDir: "{app}"; Tasks: postgres; Flags: ignoreversion

[Icons]
Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"

[Run]
Filename: "{app}\PostgresDummy.exe"; Description: "{cm:LaunchProgram, Postgres dummy app}"; Tasks: postgres;    Flags: waituntilterminated postinstall skipifsilent
Filename: "{app}\ClientDummy.exe"; Description: "{cm:LaunchProgram, Client dummy app}";     Components: client; Flags: nowait postinstall skipifsilent
Filename: "{app}\ServerDummy.exe"; Description: "{cm:LaunchProgram, Server dummy app}";     Components: server; Flags: nowait postinstall skipifsilent

Points of Interest

To access Tasks in Inno Setup [Code] sections, the following command can be used:

Pascal
IsTaskSelected('postgres')

From the Windows Start menu, or Settings, Tasks_Test can be uninstalled.

History

  • v1.0 16th October 2023: Initial version

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)