Click here to Skip to main content
15,886,873 members
Articles / Programming Languages / Pascal
Tip/Trick

Inno Setup Tasks Demystified

Rate me:
Please Sign up or sign in to vote.
5.00/5 (7 votes)
18 Oct 2023CPOL 5.2K   105   11   1
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)


Written By
Software Developer
Netherlands Netherlands
Software developer in the Netherlands, currently working on Video Surveillance applications.
Experience: C#, C++, VB, ASP, SQL Server, PostgreSQL, Gitea, TeamCity.
It all started with Black&White, no not the whiskey but the Sinclair ZX81 followed by several Atari's and PC's. The journey continues ...

Comments and Discussions

 
GeneralMy vote of 5 Pin
Ștefan-Mihai MOGA16-Oct-23 2:05
professionalȘtefan-Mihai MOGA16-Oct-23 2:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.