SteveS
SteveS

Reputation: 407

Change icon/shortcuts's command line arguments based on Inno Setup components

Using Inno Setup 6.2, I have icons set up for my app. Based on Components selection, I need to dynamically add switches to the app's cmd line in the icons. Is there a way to do this?

Upvotes: 2

Views: 76

Answers (1)

Martin Prikryl
Martin Prikryl

Reputation: 202534

If the logic is simple, use Components parameter:

[Icons]
Name: "{autoprograms}\My Program"; Filename: "{app}\MyProg.exe"; \
    Parameters: "/Client"; Components: client
Name: "{autoprograms}\My Program"; Filename: "{app}\MyProg.exe"; \
    Parameters: "/Server"; Components: server

You can reduce code repetition using preprocessor.


If the logic is more complicated, use:

[Icons]
Name: "{autoprograms}\My Program"; Filename: "{app}\MyProg.exe"; \
    Parameters: "{code:GetIconParameters}"
[Code]

function GetIconParameters(Param: String): String;
begin
  if WizardIsComponentSelected('server') then
    Result := '/Server'
  else if WizardIsComponentSelected('client') then
    Result := '/Client'
  else
    Result := '';
end;

Upvotes: 4

Related Questions