Question

I would like to have in my InnoSetup possibility to allow customer to install one of two programs or to install both.

I made additional choose panel where user check what he wants to install but I have following questions

  1. How to change hardcoded AppName?
  2. How to dynamically tell where to install program?

    For e.g. default installation dir is > Program Files\Program 1 how to change that to Program Files\Program 2

  3. How to change UninstallDisplayIcon?

    Currently UninstallDisplayIcon={app}\program1.exe

    How to change it depends of chose settings to: UninstallDisplayIcon={app}\program2.exe


Current configuration (from comment):

[Run]
Filename: {app}\{#MyAppExeName};
Description: {cm:LaunchProgram,{#MyAppName}};
Flags: nowait postinstall skipifsilent

Where MyAppExeName is currently constant defined at the beginning of the file.

My question is how to do something like this:

[Run]
Filename: {app}\MYFUNCTIONFROMCODESECTION_THAT_WILL_RETURN_NAME;
Description: {cm:LaunchProgram,{#MyAppName}};
Flags: nowait postinstall skipifsilent
Was it helpful?

Solution

How to change the AppName directive value at runtime ?

It is not possible to change the AppName directive value at runtime since it is evaluated at the installer's initialization time.

How to conditionally specify the installed file destination ?

For this you can use the {code:...} scripted constant. For instance:

[Files]
Source: "MyApp.exe"; DestDir: "{code:GetMyAppDestDir}"

[Code]
function GetMyAppDestDir(Value: string): string;
begin
  Result := '<Here return the path where the file should be installed...>';
end;

How to change the UninstallDisplayIcon directive value at runtime ?

For this you can also use the {code:...} scripted constant. For instance:

[Setup]
UninstallDisplayIcon={code:GetUninstallDisplayIcon}

[Code]
function GetUninstallDisplayIcon(Value: string): string;
begin
  Result := '<Here return the path of the icon to be used for uninstaller...>';
end;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top