Check Java is present before installing

后端 未结 7 1351
傲寒
傲寒 2021-01-30 23:46

I\'m creating an Inno Setup installer for a jar app. What I want to do right now is to check if java is present before proceeding with the install. So I only need to be sure the

7条回答
  •  庸人自扰
    2021-01-31 00:21

    A simple alternative to the already proposed answers:

    [Code]
    function InitializeSetup(): boolean;
    var
      ResultCode: integer;
    begin
      if Exec('java', '-version', '', SW_SHOW, ewWaitUntilTerminated, ResultCode) then begin
        Result := true;    
      end
      else begin          
        if MsgBox('This tool requires Java Runtime Environment version 1.6 or newer to run. Please download and install the JRE and run this setup again. Do you want to download it now?', mbConfirmation, MB_YESNO) = idYes then begin
          Result := false;
          ShellExec('open', 'https://java.com/download/', '', '', SW_SHOWNORMAL, ewNoWait, ResultCode);
        end;  
      end;
    end;
    

提交回复
热议问题