2

I have designed my installer using Inno Setup to display 2 components for the user to select. According to his/her selection, the Finish page at the end will show Launch program checkbox(es). The default value for the checkbox is false if both components have been selected.

So far, so good.

Now, I want that if only one of the components is selected for installation by the user, the default value of the checkbox should be true.

Following are the Component and Run sections of the installer,

[Components]
Name: "Component1"; Description: "Component1"; Types: full;
Name: "Component2"; Description: "Component2"; Types: full custom; 

[Run]
Filename: "{localappdata}\MyInstaller\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent unchecked; Components:Component1;
Filename: "{localappdata}\MyInstaller\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(TestAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent unchecked; Components:Component2

I understand that what I want, requires some scripting to be done. I am at a loss at what to do.

Please guide.

poortip
  • 145
  • 1
  • 2
  • 10
  • Err, *"the default value for the checkbox is false if both components have been selected"* is true, but even if you select only one of them, the check box will be unchecked. Actually, with such script you'll always get unchecked check boxes. – TLama Aug 25 '14 at 07:12
  • Yes, I know that the result of the above script gives me unchecked check box. What I want, is a checked check box if any one of the components is selected. – poortip Aug 25 '14 at 07:22

1 Answers1

4

The Components parameter allows you to use boolean expression operators so for your case you may write two pairs of entries where one is for unchecked check box and the second for checked. The rest of what you need is writing an expression:

[Components]
Name: "Component1"; Description: "Component1";
Name: "Component2"; Description: "Component2";

[Run]
; this is the entry pair for unchecked check box; it is shown if both components
; are selected
Filename: "{app}\MyProg1.exe"; Flags: nowait postinstall skipifsilent unchecked; Components: Component1 and Component2;
Filename: "{app}\MyProg2.exe"; Flags: nowait postinstall skipifsilent unchecked; Components: Component1 and Component2;
; this is the entry pair for checked check box; it is shown only when the given
; component is selected and the other not
Filename: "{app}\MyProg1.exe"; Flags: nowait postinstall skipifsilent; Components: Component1 and not Component2;
Filename: "{app}\MyProg2.exe"; Flags: nowait postinstall skipifsilent; Components: Component2 and not Component1;

That will produce:

  • no check box if no component is selected
  • two unchecked check boxes if both components are selected
  • one checked check box if only one of the components is selected
TLama
  • 75,147
  • 17
  • 214
  • 392
  • You're welcome! I forgot to mention that from scripting section you can do it only with multiple entries (one for each state) because flags cannot be changed at runtime (you cannot remove that `unchecked` flag from the entry anyhow). – TLama Aug 25 '14 at 07:38
  • Okay, thanks again! I didn't know that flags could only be set beforehand. – poortip Aug 25 '14 at 07:44
  • 1
    Flags must be known at compilation time since many of them decides how the resources (e.g. files) will be compiled into the output binary. However, it might be fine to separate these special `[Run]` entries into a standalone section like e.g. `[PostInstallRun]` or something like that. Btw. similar to your question is [`an example`](http://stackoverflow.com/q/14392921/960757) of how to define the post install check box state by the passed command line parameter (which disappointed me in its overcomplexed answer that is accepted). – TLama Aug 25 '14 at 08:02