Prechecked or unchecked components in Inno Setup custom install - inno-setup

I only need 1 custom installation type with 3 components :
The first is needed, so checked and readonly.
The second is optional but part of the default, so checked and writable.
The third is just optional, so unchecked and writable.
If I don't specify a type explicitly, I don't manage to have components checked by default.
If I specify one, I don't manage to have the last component unchecked as default.
I tried with 2 types but, it has no meaning as it's only one custom installation.
Any idea how to get the expected behavior with a single type?
[Types]
Name: "standard"; Description: "Standard installation";
Name: "custom"; Description: "Custom installation"; Flags: iscustom
[Components]
Name: "first"; Description: "First Component"; Types: standard custom; Flags: fixed
Name: "second"; Description: "Second Component"; Types: standard custom;
Name: "third"; Description: "Third Component"; Types: custom;

This should do:
[Types]
Name: "custom"; Description: "Dummy custom installation"; Flags: iscustom
[Components]
Name: "first"; Description: "First Fixed Component"; Types: custom; Flags: fixed
Name: "second"; Description: "Second Checked Component"; Types: custom
Name: "third"; Description: "Third Unchecked Component"

Related

Multiple Inno Setup Types that have optional Components

I am trying to create a Inno Setup installer (with Inno Setup 6.2.0) that has multiple setup Types where more than one can have optional Components (as well as fixed components). For example, suppose I want to have the following setup types:
Instructor
Student
If the "Instructor" setup type is selected, I would like to have an "Instructor - Fixed" component (which must be installed), plus two optional components "Instructor- Optional 1" and "Instructor - Optional 2".
Similarly for the "Student" setup type, I would like a fixed component plus a couple of optional components.
Below is the starting point for my experiments:
[Types]
Name: TYPE_INSTRUCTOR ; Description: "Instructor" ;
Name: TYPE_STUDENT ; Description: "Student" ;
[Components]
Name: COMP_INSTRUCTOR ; Description: "Instructor" ; Types: TYPE_INSTRUCTOR
Name: COMP_INSTRUCTOR\FIXED ; Description: "Instructor - Fixed" ; Types: TYPE_INSTRUCTOR ; Flags: fixed
Name: COMP_INSTRUCTOR\OPTIONAL_1 ; Description: "Instructor - Optional 1" ; Types: TYPE_INSTRUCTOR
Name: COMP_INSTRUCTOR\OPTIONAL_2 ; Description: "Instructor - Optional 2" ; Types: TYPE_INSTRUCTOR
Name: COMP_STUDENT ; Description: "Student" ; Types: TYPE_STUDENT
Name: COMP_STUDENT\FIXED ; Description: "Student - Fixed" ; Types: TYPE_STUDENT ; Flags: fixed
Name: COMP_STUDENT\OPTIONAL_1 ; Description: "Student - Optional 1" ; Types: TYPE_STUDENT
Name: COMP_STUDENT\OPTIONAL_2 ; Description: "Student - Optional 2" ; Types: TYPE_STUDENT
[Files]
Source: "InstFixed.txt" ; DestDir: {app} ; Components: COMP_INSTRUCTOR\FIXED
Source: "InstOpt1.txt" ; DestDir: {app} ; Components: COMP_INSTRUCTOR\OPTIONAL_1
Source: "InstOpt2.txt" ; DestDir: {app} ; Components: COMP_INSTRUCTOR\OPTIONAL_2
Source: "StuFixed.txt" ; DestDir: {app} ; Components: COMP_STUDENT\FIXED
Source: "StuOpt1.txt" ; DestDir: {app} ; Components: COMP_STUDENT\OPTIONAL_1
Source: "StuOpt2.txt" ; DestDir: {app} ; Components: COMP_STUDENT\OPTIONAL_2
I have tried a few different things, but nothing has succeeded in achieving what I need. I have tried:
Adding Flags: iscustom to both setup types (my thinking was to indicate that both are customisable). However, Inno Setup only seems to allow for one customisable type.
Making just one of the setup type to have Flags: iscustom (e.g. adding it to TYPE_INSTRUCTOR). However, that does not work as I would like, because I can then end up with invalid combinations, e.g. I can select a mixture of Instructor and Student components.
The only way I can think to get around this is to have setup types for every possible combination. That would not be practical (this example is not my real problem, just a simple case to illustrate it, I would end up with a very large list of setup types).
Thank you in advance for any workable solutions.
That's not possible. At least not without some heavy customization with Pascal Scripting.
Way easier is to drop the Types altogether and use two top-level mutually-exclusive components and couple of optional subcomponents:
[Types]
Name: "custom"; Description: "Custom installation"; Flags: iscustom
[Components]
Name: "intructor"; Description: "Instructor"; Flags: exclusive
Name: "intructor\opt1"; Description: "Optional 1"
Name: "intructor\opt2"; Description: "Optional 2"
Name: "student"; Description: "Student"; Flags: exclusive
Name: "student\opt1"; Description: "Optional 1"
Name: "student\opt2"; Description: "Optional 2"

Inno Setup - How to localize component and type names?

How to localize component and type names? For example:
[Languages]
Name: "eng"; MessagesFile: "Idiomas\English.isl"
Name: "spa"; MessagesFile: "Idiomas\Spanish.isl"
If I choose English:
[Types]
Name: "full"; Description: "Full installation"
Name: "compact"; Description: "Compact installation"
Name: "custom"; Description: "Custom installation"; Flags: iscustom
[Components]
Name: "program"; Description: "Program Files"; Types: full compact custom; \
Flags: fixed
Name: "readme"; Description: "Readme File"; Types: full
or if I choose Spanish:
[Types]
Name: "full"; Description: "Instalación Completa"
Name: "compact"; Description: "Instalación Mínima"
Name: "custom"; Description: "Instalación Personalizada"; Flags: iscustom
[Components]
Name: "program"; Description: "Archivos de Programa"; Types: full compact custom; \
Flags: fixed
Name: "readme"; Description: "Archivo de Ayuda"; Types: full
Define custom messages in the language files:
idiomas\English.isl:
[CustomMessages]
FullInstallation=Full installation
CompactInstallation=Compact installation
CustomInstallation=Custom installation
ProgramFilesComponent=Program Files
ReadmeFileComponent=Readme File
idiomas\Spanish.isl:
[CustomMessages]
FullInstallation=Instalación Completa
CompactInstallation=Instalación Mínima
CustomInstallation=Instalación Personalizada
ProgramFilesComponent=Archivos de Programa
ReadmeFileComponent=Archivo de Ayuda
or you can use the [CustomMessages] section in the main .iss file:
[CustomMessages]
eng.FullInstallation=Full installation
spa.FullInstallation=Instalación Completa
...
And then use these custom messages using the {cm:MessageName} constant in your script:
[Types]
Name: "full"; Description: "{cm:FullInstallation}"
Name: "compact"; Description: "{cm:CompactInstallation}"
Name: "custom"; Description: "{cm:CustomInstallation}"; Flags: iscustom
[Components]
Name: "program"; Description: "{cm:ProgramFilesComponent}"; \
Types: full compact custom; Flags: fixed
Name: "readme"; Description: "{cm:ReadmeFileComponent}"; \
Types: full

Select Component exclusively ( InnoSetup )

Two Components are displayed well with below code.
If I select 'Server' component, then 'Client' component should be unchecked.
If I select 'Client' component, then 'Server' component should be unchecked.
Can you let me know how I can do that?
[Files]
Source: "C:\MAEK\bin\MAEK\*.exe"; DestDir: "{app}\bin\"; Flags: ignoreversion ; Components: Server
Source: "C:\MAEK\bin\MAEK\*.exe"; DestDir: "{app}\bin\"; Flags: ignoreversion ; Components: Client
[Types]
Name: "custom"; Description: "Custom installation"; Flags: iscustom
[Components]
Name: "Server"; Description: "Server"; Types: custom;
Name: "Client"; Description: "Client"; Types: custom;
Only 1 component to choose??
[Components]
Name: "Server"; Description: "Server"; Types: custom; Flags: exclusive
Name: "Client"; Description: "Client"; Types: custom; Flags: exclusive
If more:
[Components]
Name: "Mode"; Description: "Installation Mode"; Types: custom; Flags: fixed
Name: "Mode\Server"; Description: "Server"; Types: custom; Flags: exclusive
Name: "Mode\Client"; Description: "Client"; Types: custom; Flags: exclusive

Inno setup: don't show option if it is not checked

After looking at this example Inno Setup: Function to select a component I've added another option to my code but what I'm trying to do (and I don't know if it is possible) is that if in the components section an option hasn't been marked, I don't want it to appear in Page1.Add('help'); or Page1.Add('readme\de');
[Setup]
AppName=My Program
AppVerName=My Program v.1.2
DefaultDirName={pf}\My Program
[Types]
Name: full; Description: Full installation
Name: compact; Description: Compact installation
Name: custom; Description: Custom installation; Flags: iscustom
[Components]
Name: program; Description: Program Files; Types: full compact custom; Flags: fixed
Name: help; Description: Help File; Types: full
Name: readme; Description: Readme File; Types: full
Name: readme\en; Description: English; Flags: exclusive
Name: readme\de; Description: German; Flags: exclusive
[Code]
var
Page1: TInputOptionWizardPage;
Procedure BackupCheckCreate();
var
StaticText: TNewStaticText;
begin
Page1 := CreateInputOptionPage(wpReady, 'Optional Actions Test',
'Which actions should be performed?',
'Please select all optional actions you want to be performed, then click Next.', False, False);
Page1.Add('help');
Page1.Add('readme\de');
Page1.Values[0] := False;
Page1.Values[1] := False;
end;
function ShouldSkipPage(PageID: Integer): Boolean;
begin
Result := (PageID = Page1.ID) and (not IsComponentSelected('help') and not IsComponentSelected('readme\de'));
end;
procedure InitializeWizard();
begin
BackupCheckCreate();
end;
There is no easy way to hide items from TInputOptionWizardPage or generally any custom page at this time. So conditional showing certain check box items on your options page by selected components is not an easy task. So before digging into some hacky ways I would suggest you another way.
From the caption of the page you are creating it looks like you need the [Tasks] section. This section allows you to create additional task check boxes with simple binding to the selected components. Check this example:
[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={pf}\My Program
[Types]
Name: full; Description: Full installation
Name: compact; Description: Compact installation
Name: custom; Description: Custom installation; Flags: iscustom
[Components]
Name: main; Description: "Program Files"; Types: full compact custom; Flags: fixed
Name: backup; Description: "Backup DB"; Types: full
Name: restore; Description: "Restore DB"; Types: full
[Tasks]
; if "backup" component is selected, these two tasks appear
Name: backuptask1; Description: "Backup 1"; GroupDescription: "Backup Tasks:"; Components: backup
Name: backuptask2; Description: "Backup 2"; GroupDescription: "Backup Tasks:"; Components: backup
; if "restore" component is selected, these two tasks appear
Name: restoretask1; Description: "Restore 1"; GroupDescription: "Restore Tasks:"; Components: restore
Name: restoretask2; Description: "Restore 2"; GroupDescription: "Restore Tasks:"; Components: restore

Inno Setup - Correct use of [Types], [Components] and [Tasks]

I am writing a script that requires users to choose which parts of the application to install:
Application only, DataBase Engine only, Data only, or any combination of these.
I know I should be using the [Components] section to define these, but I am getting confused by the interplay between Types, Components and Tasks - for one, I thought [Tasks] was for "extra" installations, but then I saw code that links explicitly the three.
Can anyone point me to a good explanation of how these work together? - I am sure there is one...
Thanks
Components are made of one or more Types. In the script you'll use the Components as selector depending on the Type chosen by the end user. Components can be used in the Tasks because depending on the Types chosen by the user a Task will have or not to be executed.
For example:
; 'Types': What get displayed during the setup
[Types]
Name: "full"; Description: "Full installation";
Name: "app"; Description: "Fapplication only";
Name: "dbengine"; Description: "Database engine only";
Name: "data"; Description: "Data only";
; Components are used inside the script and can be composed of a set of 'Types'
[Components]
Name: "full"; Description: "Full installation"; Types: full app dbengine app
Name: "app"; Description: "Fapplication only"; Types: app
Name: "dbengine"; Description: "Database engine only";Types: dbengine
Name: "data"; Description: "Data only"; Types: data
; Defines which files are setup, based on the differents components
[Files]
Source: "MyApp.exe"; DestDir: "{app}"; Flags: ignoreversion; Components: full app
Source: "ADll.dll"; DestDir: "{app}"; Flags: ignoreversion; Components: full app
Source: "Engine.dll"; DestDir: "{app}"; Flags: ignoreversion; Components: full dbengine
Source: "data_0"; DestDir: "{app}"; Flags: ignoreversion; Components: full data
Source: "data_1"; DestDir: "{app}"; Flags: ignoreversion; Components: full data
; In the same fashion, a task can be set for a specific component
[Tasks]
Name: desktopicon; Description: "Create a &desktop icon"; GroupDescription: "Additional icons:"; Components: full app
My understanding is that a Component is a basically a set of files - it constitutes a major 'component' of what can be installed. A 'type' of installation is a selection of components that it makes sense to install together. Here's the way I would code #az01 's example.
; Lists types of installations - the user is presented
; with a list containing these Descriptions:
[Types]
Name: "full"; Description: "Full installation";
Name: "app-only"; Description: "Application only";
Name: "engine-only"; Description: "Database engine only";
Name: "data-only"; Description: "Data only";
; This lists the installable components of the product and
; specifies which type of install they are included in
[Components]
Name: "app"; Description: "Application"; Types: full app-only
Name: "engine"; Description: "Database engine"; Types: full engine-only
Name: "data"; Description: "Data"; Types: full data-only
; each file is assigned to one component, unless it is shared between
; components, in which case maybe it should go in a 'shared' component.
[Files]
Source: "MyApp.exe"; DestDir: "{app}"; Flags:; Components: app
Source: "ADll.dll"; DestDir: "{app}"; Flags:; Components: app
Source: "Engine.dll"; DestDir: "{app}"; Flags:; Components: engine
Source: "data_0"; DestDir: "{app}"; Flags: ignoreversion; Components: data
Source: "data_1"; DestDir: "{app}"; Flags: ignoreversion; Components: data
A complete explanation can be found on Innosetup help page :
Components and Tasks Parameters
and [Components] section
I give you below a generic sample :
[Components]
Name: a; Description: a
Name: b; Description: b
[Tasks]
Name: p; Description: a or b; Components: a or b
Name: q; Description: a and b; Components: a and b
Name: r; Description: not a or b; Components: not a or b
Name: s; Description: not (a or b); Components: not (a or b)
Name: t; Description: a or b - old style; Components: a b

Resources