Run installation using Inno Setup silently without

2019-05-20 07:59发布

问题:

I want my installation should be silent without any Next or Install buttons clicked by the user. I tried to disable all pages still, I am getting the "Ready to Install" page. I want avoid this install page.

回答1:

To run an installer built in Inno Setup without any interaction with the user or even without any window, use the /SILENT or /VERYSILENT command-line parameters:

Instructs Setup to be silent or very silent. When Setup is silent the wizard and the background window are not displayed but the installation progress window is. When a setup is very silent this installation progress window is not displayed. Everything else is normal so for example error messages during installation are displayed and the startup prompt is (if you haven't disabled it with DisableStartupPrompt or the '/SP-' command line option explained above).


You may also consider using the /SUPPRESSMSGBOXES parameter.


If you want to make your installer run "silently" with any additional command-line switches, you can:

  • Use the ShouldSkipPage event function to skip most pages.
  • Use a timer to skip the "Ready to Install" page (which cannot be skipped using the ShouldSkipPage). You can use the technique shown in Inno Setup - How to close finished installer after a certain time?
[Files]
Source: "InnoCallback.dll"; Flags: dontcopy

[Code]

type
  TTimerProc = procedure(HandleW, msg, idEvent, TimeSys: LongWord);

function SetTimer(hWnd, nIDEvent, uElapse, lpTimerFunc: LongWord): LongWord;
  external 'SetTimer@User32.dll stdcall';
function KillTimer(hWnd, nIDEvent: LongWord): LongWord;
  external 'KillTimer@User32.dll stdcall';

function WrapTimerProc(Callback: TTimerProc; ParamCount: Integer): LongWord;
  external 'wrapcallback@files:InnoCallback.dll stdcall delayload';

var
  SubmitPageTimer: LongWord;

procedure KillSubmitPageTimer;
begin
  KillTimer(0, SubmitPageTimer);
  SubmitPageTimer := 0;
end;  

procedure SubmitPageProc(H: LongWord; Msg: LongWord; IdEvent: LongWord; Time: LongWord);
begin
  WizardForm.NextButton.OnClick(WizardForm.NextButton);
  KillSubmitPageTimer;
end;

procedure CurPageChanged(CurPageID: Integer);
begin
  if CurPageID = wpReady then
  begin
    SubmitPageTimer := SetTimer(0, 0, 100, WrapTimerProc(@SubmitPageProc, 4));
  end
    else
  begin
    if SubmitPageTimer <> 0 then
    begin
      KillSubmitPageTimer;
    end;
  end;
end;

function ShouldSkipPage(PageID: Integer): Boolean;
begin
  Result := True;
end;

The code uses the InnoTools InnoCallback library to implemented the timer.

Another approach is to send CN_COMMAND to the Next button, as show here: How to skip all the wizard pages and go directly to the installation process?