How to detect whether the setup runs in very silen

2019-01-15 07:05发布

问题:

I know there is the WizardSilent function for checking whether the setup runs in silent mode, but I cannot find a function equivalent for very silent mode (when the setup is executed with /VERYSILENT command line parameter).

Is there a way to detect whether the setup runs in very silent mode?

回答1:

WizardSilent will be true for both /Silent and /VerySilent installs. The difference between the two parameters is whether a progress bar is shown (/Silent) or not (/VerySilent).

Based on your comment, the best I can suggest would be to check the command line and look for /VerySilent and set a global variable. Something like:

[Code]
var 
  isVerySilent: Boolean;

function InitializeSetup(): Boolean;
var
  j: Integer;
begin
  isVerySilent := False;
  for j := 1 to ParamCount do
    if CompareText(ParamStr(j), '/verysilent') = 0 then
    begin
      isVerySilent := True;
      Break;
    end; 

  if isVerySilent then
    Log ('VerySilent')
  else
    Log ('not VerySilent');
end;


回答2:

This one works better... its compatible with multiple params in command line

var
j: Cardinal;
begin

isVerySilent := false;   
begin
  for j := 0 to ParamCount do
    begin
    MsgBox('param'+ParamStr(j), mbInformation, MB_OK);
      if ParamStr(j)='/verysilent'   then
        isVerySilent := true;

    end; 
  if isVerySilent then begin
    Log ('VerySilent')
  end else
    Log ('not VerySilent');
end;


标签: inno-setup