Inno Setup Run code according to setup type

Luca

I want to provide a couple of different installation types performing different operations to my installer: if "ApplicationServer" type is selected, only perform part of the code. If Client type is selected instead, only perform this part of the procedure.

I tried to include the 2 "blocks" of code within a function called

[Types]
Name: "application"; Description: "{cm:ApplicationServer}"
Name: "client"; Description: "{cm:Client}"

[CustomMessages]
ApplicationServer=Application Server:
Client=Client:

If first choice selected, I want to perform a specific code made of several procedures, constant, variables to run a sequence of SQL script, while if second is chosen I need to perform some other stuffs into the code area, like this:

[Code]

function ApplicationServer(blabla)
begin:
  { <!This part only to run for ApplicationServer type!> }
  { following constants and variables for the ADO Connection + SQL script run }
  const
    myconstant1=blabla;
  var
    myvar1=blabla;    
  { here all the procedure to define and manage an ADO Connection to run a sql script }
  { procedure 1 }
  { procedure 2 }
end

function Client(blabla)
begin:
  { <!This part only to run for Client type!> }
  { following constants and variables only for performing some stuffs on top of client }
  const
    myconstant2=blabla;
  var
    myvar2=blabla;
  { procedure 3 }
  { procedure 4 }
end

Is there a way to manage a specific part of the code to run according the type of installation running?

Thanks.

Martin Prikryl

Use WizardSetupType support function.

You will probably want to check in CurStepChanged event function.

procedure ApplicationServer;
begin
  { procedure 1 }
  { procedure 2 }
end;

procedure Client;
begin
  { procedure 1 }
  { procedure 2 }
end;

procedure CurStepChanged(CurStep: TSetupStep);
var
  SetupType: string;
begin
  Log(Format('CurStepChanged %d', [CurStep]));

  if CurStep = ssInstall then
  begin
    SetupType := WizardSetupType(False);

    if SetupType = 'application' then
    begin
      Log('Installing application server');
      ApplicationServer;
    end
      else
    if SetupType = 'client' then
    begin
      Log('Installing client');
      Client;
    end
      else
    begin
      Log('Unexpected setup type: ' + SetupType);
    end;
  end;
end;

The Pascal script does not support local constants, only global constants.

It's not clear anyway, what you want, if you want a local constant or initialize a global constant conditionally. You cannot do the latter anyway, a constant is constant, it cannot have a different value.

The same with your variables. Are these local variables or do you want to set a value to a global variable conditionally?

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Inno Setup: How to pass variable from [Code] to [Run] (or other section)

From Dev

Inno Setup: How to pass variable from [Code] to [Run] (or other section)

From Dev

Inno Setup Section [Run] with condition

From Dev

upgrade code equivalent in Inno setup

From Dev

Inno Setup : {code: ...} not working for OutputBaseFilename?

From Dev

Inno setup code to install python

From Dev

Inno Setup: How to run a code procedure in Run section or before Run section?

From Dev

Inno Setup: Run program without showing a checkbox

From Dev

Inno Setup: Execute a Pascal function in [Run] section

From Dev

Inno Setup, spaces and double quote in [Run]

From Dev

Inno Setup: Run program without showing a checkbox

From Dev

Inno Setup Remember selected setup type when Uninstallable=no

From Dev

inno setup giving error code 2 with mysql setup

From Dev

Inno Setup - no 64 Bit data type?

From Dev

Convert Single data type to string in inno setup

From Dev

How to check partition type in inno setup?

From Dev

Inno Setup "return" like command/construct in Code

From Dev

Inno setup: detect installation based on product code

From Dev

Using constants and code in procedure calls (inno setup)

From Dev

Inno Setup Code section create hidden file

From Dev

Inno Setup [Code] section variable to [Registry]

From Dev

Inno setup: detect installation based on product code

From Dev

Inno Setup "return" like command/construct in Code

From Dev

How to set Launch program according to components selected in Inno Setup?

From Dev

Inno Setup find subfolder

From Dev

"Not in a loop " error in inno setup

From Dev

Inno Setup Exception is not caught

From Dev

Create a hardlink with Inno Setup

From Dev

Inno Setup Message Arguments

Related Related

  1. 1

    Inno Setup: How to pass variable from [Code] to [Run] (or other section)

  2. 2

    Inno Setup: How to pass variable from [Code] to [Run] (or other section)

  3. 3

    Inno Setup Section [Run] with condition

  4. 4

    upgrade code equivalent in Inno setup

  5. 5

    Inno Setup : {code: ...} not working for OutputBaseFilename?

  6. 6

    Inno setup code to install python

  7. 7

    Inno Setup: How to run a code procedure in Run section or before Run section?

  8. 8

    Inno Setup: Run program without showing a checkbox

  9. 9

    Inno Setup: Execute a Pascal function in [Run] section

  10. 10

    Inno Setup, spaces and double quote in [Run]

  11. 11

    Inno Setup: Run program without showing a checkbox

  12. 12

    Inno Setup Remember selected setup type when Uninstallable=no

  13. 13

    inno setup giving error code 2 with mysql setup

  14. 14

    Inno Setup - no 64 Bit data type?

  15. 15

    Convert Single data type to string in inno setup

  16. 16

    How to check partition type in inno setup?

  17. 17

    Inno Setup "return" like command/construct in Code

  18. 18

    Inno setup: detect installation based on product code

  19. 19

    Using constants and code in procedure calls (inno setup)

  20. 20

    Inno Setup Code section create hidden file

  21. 21

    Inno Setup [Code] section variable to [Registry]

  22. 22

    Inno setup: detect installation based on product code

  23. 23

    Inno Setup "return" like command/construct in Code

  24. 24

    How to set Launch program according to components selected in Inno Setup?

  25. 25

    Inno Setup find subfolder

  26. 26

    "Not in a loop " error in inno setup

  27. 27

    Inno Setup Exception is not caught

  28. 28

    Create a hardlink with Inno Setup

  29. 29

    Inno Setup Message Arguments

HotTag

Archive