Run installation using Inno Setup silently without any Next button or Install button

后端 未结 1 1431
别那么骄傲
别那么骄傲 2020-12-06 20:36

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 \

相关标签:
1条回答
  • 2020-12-06 21:37

    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" without 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?
    [Code]
    
    function SetTimer(hWnd, nIDEvent, uElapse, lpTimerFunc: LongWord): LongWord;
      external 'SetTimer@User32.dll stdcall';
    function KillTimer(hWnd, nIDEvent: LongWord): LongWord;
      external 'KillTimer@User32.dll stdcall';
    
    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, CreateCallback(@SubmitPageProc));
      end
        else
      begin
        if SubmitPageTimer <> 0 then
        begin
          KillSubmitPageTimer;
        end;
      end;
    end;
    
    function ShouldSkipPage(PageID: Integer): Boolean;
    begin
      Result := True;
    end;
    

    For CreateCallback function, you need Inno Setup 6. If you are stuck with Inno Setup 5, you can use WrapCallback function from InnoTools InnoCallback library.

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

    0 讨论(0)
提交回复
热议问题