java - Inno 安装程序 : How to check if JRE is present and prompt to download if not?

标签 java installation virtual-machine inno-setup setup-project

我正在使用 Inno Setup 开发 Java 64 位应用程序的安装程序。

Inno Setup 可以检查计算机中是否存在 Java 64 位,如果没有则向用户显示 Java 64 位下载链接?

我应该在 Inno Setup 脚本中添加什么来实现该行为?

最佳答案

您可以在下面找到一个脚本,该脚本可以检查是否安装了 JRE,然后为用户提示一条消息我使用这篇 Stack Overflow 帖子作为引用:How do I install a JRE from an Inno Setup?

[Code]
{ Script to check if a JRE is installed }

function InitializeSetup(): Boolean;
var
  ErrorCode: Integer;
  JavaVer: string;
begin
    RegQueryStringValue(
        HKLM, 'SOFTWARE\JavaSoft\Java Runtime Environment', 'CurrentVersion', JavaVer);
    Result := (Length(JavaVer) > 0);
    if not Result then
    begin
        if MsgBox('YOUR MESSAGE GOES HERE', mbConfirmation, MB_YESNO) = idYes then
        begin
            ShellExec(
              'open', 'https://www.java.com/en/download/manual.jsp#win',
              '', '', SW_SHOWNORMAL, ewNoWait, ErrorCode);
        end;
    end;
end;

关于java - Inno 安装程序 : How to check if JRE is present and prompt to download if not?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54055927/

相关文章:

java - 错误 "Attempt to invoke virtual method ' 双 java.lang.Double.doubleValue( )' on a null object reference"

java - 在 Java 中拆分字符串

ios - 在Mac上为iOS开发设置FPC和Lazarus

service - 在安装过程中授予 "Log on as a service"权限和服务登录帐户(Installshield 2010)

java - 如何使用 Spring + iBatis 解决我的应用程序中的设计问题

java - 用 mockito 模拟一个静态方法

c++ - Boost库在ubuntu上产生错误

virtual-machine - 你在你的 vagrant (vm) 中运行 yeoman/gruntjs

azure - 备份 Microsoft Azure 虚拟机

docker - 将vm附加到kubernetes节点列表