4

I want some registry entries to be written if two conditions are met:

  • the installer is running in silent mode and
  • I have some command line parameters present.

Is there a way to do this in the [Registry] section?

I have something similar in the [Run] section:

Filename: "{app}\AppWithParams.exe"; Parameters: "{code:BuildParams}"; \
   Flags: postinstall skipifsilent; \
   Description: "This program needs some parameters"
[Code]
function BuildParams(Param: string): string;
begin
  Result := Format('/p1="%s" /p2="%s" /p3="%s"', [
                      ExpandConstant('{param:p1|}'), 
                      ExpandConstant('{param:p2|}'),
                      ExpandConstant('{param:p3|}')]);
end;

I've seen that [Registry] entries can be made dependent of a [Task] but I need them only in silent mode so I think this approach won't serve me.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
Héctor C.
  • 433
  • 4
  • 17

1 Answers1

4

Use Check parameter:

[Registry]
Root: HKLM; Subkey: "Software\My Company"; Check: ShouldCreateRegistry
[Code]

function ShouldCreateRegistry: Boolean;
begin
  Result := WizardSilent and CmdLineParamExists('/CreateRegistry');
end;

Such trivial Check function can actually be inlined:

[Registry]
Root: HKLM; Subkey: "Software\My Company"; \
    Check: WizardSilent and CmdLineParamExists('/CreateRegistry')
Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992