2

Basically what I'm trying to achieve is the following:

If the user run the setup with the /SILENT or /VERYSILENT parameters, the setup will immediately present the EULA. If the user rejects, the install is canceled. If the user accepts, the rest of the install will happen in silent or verysilent mode.

Edit: both solutions presented by RobeN and TLama worked perfectly. The only problem is when the EULA is too big to fit a Message Box (that would be the most common situation). Anyway that's a good solution to at least display some warning or information before the install begins.

AlexC
  • 383
  • 8
  • 17

2 Answers2

1

I do not think you can do that directly.

But you can introduce another command-line option, like /AUTOMATIC, that does what you need.

[Code]

function ShouldSkipPage(PageID: Integer): Boolean;
begin
  Result :=
    (Pos('/AUTOMATIC', Uppercase(GetCmdTail())) > 0) and
    (PageID <> wpLicense);
end;
Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
  • Nope. This question asks if it's possible to display the license when the setup runs in silent mode. The answer is making your own form from the `InitializeSetup` event handler because the license is not displayed and automatically accepted in case of silent mode. – TLama Apr 13 '15 at 07:28
  • @TLama I understand that. I know there's better (but more complicated) answer than mine. I've posted this in case it's satisfactory to OP. It's not clear whether OP needs a way to force the license display, or just an installation mode that shows the license, but nothing else. – Martin Prikryl Apr 13 '15 at 07:34
  • The words *if the user rejects, the install is canceled.* is clear enough that it's about a window with the license that the user accepts or decline. Besides, you'd better test `PageID <> wpLicense` first to not waste your time on checking the command line tail for each page ;-) – TLama Apr 13 '15 at 07:44
1

Simple solution - probably not the best, but quite fast.

Based on How to detect whether the setup runs in very silent mode?

[Files]
Source: "EULA_ANSI.txt"; DestDir: "{tmp}"; Flags: dontcopy nocompression

[Code]
var 
  isSilent: Boolean;
  EULAText: AnsiString;

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

  if isSilent then begin
    ExtractTemporaryFile('EULA_ANSI.TXT');
    if LoadStringFromFile(ExpandConstant('{tmp}\EULA_ANSI.txt'), 
     EULAText) then 
    begin
      if MsgBox(EULAText, mbConfirmation, MB_YESNO) = IDNO then
        result := false;
    end
    else begin
      MsgBox('Unable to display EULA.' + #13#10 + #13#10 + 
       'Installation terminated!', mbCriticalError, MB_OK);
      result := false;
    end;   
  end
  else begin
    MsgBox(ExpandConstant('Standard Installation'), mbInformation,
     MB_OK);
  end;
end;
Community
  • 1
  • 1
RobeN
  • 5,346
  • 1
  • 33
  • 50
  • 2
    Here should be [`the same`](http://pastebin.com/Ph8ERD0i), just a bit shorter... Message box is fine as long as you have a short EULA (or big monitor :) – TLama Apr 13 '15 at 10:37
  • Both solutions presented by RobenN and @TLama work perfectly. However, the EULA is too big to fit in a Message Box... Is there a way to present the EULA in something like a textbox with vertical scroll? Thanks! – AlexC Apr 13 '15 at 18:29
  • You would have to write your own `Form` as Inno Setup's `Wizard` is not displayed in `Silent` and `Verysilent` modes. And that is not so easy. Maybe you could modify your plan and use e.g. `ShouldSkipPage(PageID: Integer): Boolean;` function instead of `Silent` mode to override default Wizard behaviour what would be faster solution as Martin suggested. – RobeN Apr 13 '15 at 19:45
  • Is it possible to print or echo the extracted EULA_ANSI.txt to std out? – ariestav Oct 04 '22 at 12:45