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

wcc

How can I pass a variable from [Code] section to parameters in [Run] section in Inno Setup?

Basically, I want to do the following.

  1. Get and save user input to a variable in a procedure InitializeWizard.
  2. Pass the user input to an executable in [Run] section

Here is my code.

[Run]
Filename: "someProgram.exe"; Parameters: ??userInput??

[Code]
procedure InitializeWizard;
var 
  ConfigPage: TInputQueryWizardPage;
  UserInput: String;
begin
  { Create the page }
  ConfigPage :=
    CreateInputQueryPage(
      wpWelcome, 'User input', 'User input',
      'Please specify the following information, then click Next.');

  { Add items (False means it's not a password edit) }
  ConfigPage.Add('Input here:', False);
  { Set initial values (optional) }
  ConfigPage.Values[0] := ExpandConstant('hello');
  { Read values into variables }
  UserInput := ConfigPage.Values[0];
end;

Thanks.

TLama

You're looking for the scripted constant. See the following example:

[Run]
Filename: "SomeProgram.exe"; Parameters: {code:GetParams}

[Code]
var
  ConfigPage: TInputQueryWizardPage;

function GetParams(Value: string): string;
begin
  Result := ConfigPage.Values[0];
end;

procedure InitializeWizard;
begin
  { Create the page }
  ConfigPage :=
    CreateInputQueryPage(
      wpWelcome, 'User input', 'User input',
      'Please specify the following information, then click Next.');
  { Add items (False means it's not a password edit) }
  ConfigPage.Add('Input here:', False);
  { Set initial values (optional) }
  ConfigPage.Values[0] := ExpandConstant('hello');
end;

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

Using global string script variable in Run or other section in Inno Setup

From Dev

Using global string script variable in Run or other section in Inno Setup

From Dev

How to set registry key (environment variable) with value from [Code] section of Inno Setup?

From Dev

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

From Dev

Inno Setup [Code] section variable to [Registry]

From Dev

How to completely disable specific component in Inno Setup from code section?

From Dev

Inno Setup Section [Run] with condition

From Dev

Inno Setup: How to manipulate progress bar on Run section?

From Dev

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

From Dev

Inno Setup Code section create hidden file

From Dev

Inno Setup Run code according to setup type

From Dev

How to pass parameters from Java FX Ant task to Inno Setup?

From Dev

How to set a global environment variable from Inno Setup installer?

From Dev

Inno setup error handeling (ignore) in RUN Section commands

From Dev

Execute different command in Inno Setup Run section based on Windows version

From Dev

Create desktop link Icon after the Run section of Inno Setup

From Dev

Inno Setup Iterate over [Files] section in Pascal code

From Dev

Inno Setup: copy folder, subfolders and files recursively in Code section

From Dev

How can I use values from the [Setup] section in code?

From Dev

Pass argument (/verysilent) to application (subinstaller) executed from Pascal code in Inno Setup

From Dev

How to use a Pascal variable in Inno Setup?

From Dev

Inno Setup: Install other installer and run it before continuing my install

From Dev

Inno Setup: How to manipulate progress bar on Registering section?

From Dev

How can I set the exit code from return code of my Execute File in Inno Setup?

From Dev

Environment variable not recognized [not available] for [Run] programs in Inno Setup

From Dev

How to call "npm install" from Inno Setup?

From Dev

Inno Setup - Run InstallUtil from .Net 4.5 Location

From Dev

Execute different BLOCK of commands in Inno Setup Run section based on Windows version

Related Related

  1. 1

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

  2. 2

    Using global string script variable in Run or other section in Inno Setup

  3. 3

    Using global string script variable in Run or other section in Inno Setup

  4. 4

    How to set registry key (environment variable) with value from [Code] section of Inno Setup?

  5. 5

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

  6. 6

    Inno Setup [Code] section variable to [Registry]

  7. 7

    How to completely disable specific component in Inno Setup from code section?

  8. 8

    Inno Setup Section [Run] with condition

  9. 9

    Inno Setup: How to manipulate progress bar on Run section?

  10. 10

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

  11. 11

    Inno Setup Code section create hidden file

  12. 12

    Inno Setup Run code according to setup type

  13. 13

    How to pass parameters from Java FX Ant task to Inno Setup?

  14. 14

    How to set a global environment variable from Inno Setup installer?

  15. 15

    Inno setup error handeling (ignore) in RUN Section commands

  16. 16

    Execute different command in Inno Setup Run section based on Windows version

  17. 17

    Create desktop link Icon after the Run section of Inno Setup

  18. 18

    Inno Setup Iterate over [Files] section in Pascal code

  19. 19

    Inno Setup: copy folder, subfolders and files recursively in Code section

  20. 20

    How can I use values from the [Setup] section in code?

  21. 21

    Pass argument (/verysilent) to application (subinstaller) executed from Pascal code in Inno Setup

  22. 22

    How to use a Pascal variable in Inno Setup?

  23. 23

    Inno Setup: Install other installer and run it before continuing my install

  24. 24

    Inno Setup: How to manipulate progress bar on Registering section?

  25. 25

    How can I set the exit code from return code of my Execute File in Inno Setup?

  26. 26

    Environment variable not recognized [not available] for [Run] programs in Inno Setup

  27. 27

    How to call "npm install" from Inno Setup?

  28. 28

    Inno Setup - Run InstallUtil from .Net 4.5 Location

  29. 29

    Execute different BLOCK of commands in Inno Setup Run section based on Windows version

HotTag

Archive