inno-setup – 需要关于Inno安装脚本的帮助 – 检查jre安装问题
发布时间:2020-12-15 09:30:06 所属栏目:大数据 来源:网络整理
导读:我使用以下脚本来安装 Java程序.我正面临着这个脚本的2个问题. 如果您知道这些问题的解决方案,请通知我.我非常感谢您的时间 JRE检查发生了2次,即安装开始和安装结束.我希望JRE检查仅在安装开始时发生 我正在检查下面的Windows注册表项以检查JRE,并且此脚本不
我使用以下脚本来安装
Java程序.我正面临着这个脚本的2个问题.
如果您知道这些问题的解决方案,请通知我.我非常感谢您的时间 > JRE检查发生了2次,即安装开始和安装结束.我希望JRE检查仅在安装开始时发生 ; Script generated by the Inno Setup Script Wizard. ; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! #define MyAppName "Test" #define MyAppVersion "1.0" #define MyAppPublisher "Test" #define MyAppURL "gmail.com" #define MyAppExeName "abc.exe" #define MinJRE "1.6" [Setup] ; NOTE: The value of AppId uniquely identifies this application. ; Do not use the same AppId value in installers for other applications. ;(To generate a new GUID,click Tools | Generate GUID inside the IDE.) AppId={{200DC169-9647-4295-91B4-B1D1D8482B82} AppName={#MyAppName} AppVersion={#MyAppVersion} ;AppVerName={#MyAppName} {#MyAppVersion} AppPublisher={#MyAppPublisher} AppPublisherURL={#MyAppURL} AppSupportURL={#MyAppURL} AppUpdatesURL={#MyAppURL} DefaultDirName={userdocs}xsxsxsbvb DisableDirPage=yes DefaultGroupName=test DisableProgramGroupPage=yes AllowNoIcons=yes LicenseFile=C:testInstallers_PC_MACCORRECTIONS_TO_INSTALLER_BUGSTemsOfUse.txt OutputDir=C:testtest OutputBaseFilename=test SetupIconFile=C:testInstallers_PC_MACCORRECTIONS_TO_INSTALLER_BUGSIconicon.ico Compression=lzma SolidCompression=yes PrivilegesRequired=lowest [Tasks] Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked; OnlyBelowVersion: 0,6.1 [Dirs] Name: "{app}Graphics" Name: "{app}lib" Name: "{app}Database" Name: "{app}Grades" Name: "{app}HelpFiles" Name: "{app}images" Name: "{app}Scripts" [Files] Source: "C:testInstallers_PC_MACCORRECTIONS_TO_INSTALLER_BUGStest.exe"; DestDir: "{app}"; Flags: ignoreversion; Source: "C:testInstallers_PC_MACCORRECTIONS_TO_INSTALLER_BUGSGraphics*"; DestDir: "{app}Graphics"; Flags: ignoreversion recursesubdirs createallsubdirs Source: "C:testInstallers_PC_MACCORRECTIONS_TO_INSTALLER_BUGSlib*"; DestDir: "{app}lib"; Flags: ignoreversion recursesubdirs createallsubdirs Source: "C:testInstallers_PC_MACCORRECTIONS_TO_INSTALLER_BUGSDataBase*"; DestDir: "{app}DataBase"; Flags: ignoreversion recursesubdirs createallsubdirs Source: "C:testInstallers_PC_MACCORRECTIONS_TO_INSTALLER_BUGSGrades*"; DestDir: "{app}Grades"; Flags: ignoreversion recursesubdirs createallsubdirs [Icons] Name: "{group}test"; Filename: "{app}{#MyAppExeName}" Name: "{group}{cm:uninstallProgram,test}"; Filename: "{uninstallexe}" Name: "{commondesktop}{#MyAppName}"; Filename: "{app}{#MyAppExeName}"; Tasks: desktopicon Name: "{userappdata}MicrosoftInternet ExplorerQuick Launch{#MyAppName}"; Filename: "{app}{#MyAppExeName}"; Tasks: quicklaunchicon [Run] Filename: "{app}{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName,'&','&&')}}";check:InitializeSetup; Flags: nowait postinstall skipifsilent [Code] function installJRE(): Boolean; var Result1 : Boolean; ErrorCode: Integer; begin Result1 := false; Result1 := MsgBox('Java is required to run the program you are trying to install. Please click on Yes button given below to close this installer and be directed to a website were you can download and install Java.',mbConfirmation,MB_YESNO) = idYes; if Result1 = false then begin // user can install the Java later also Result:=true; end else begin Result:=false; ShellExec('open','http://www.oracle.com/technetwork/java/javase/downloads/jre6downloads-1902815.html','',SW_SHOWNORMAL,ewNoWait,ErrorCode); end; end; function InitializeSetup(): Boolean; var jreVersion: String; begin Result := False; if ((RegValueExists(HKEY_LOCAL_MACHINE,'SOFTWAREJavaSoftJava Runtime Environment','CurrentVersion'))) then begin RegQueryStringValue(HKLM,'SoftwareJavaSoftJava Runtime Environment','CurrentVersion',jreVersion); if CompareStr(jreVersion,'{#MinJRE}') > 0 then begin Result:=true; end else begin if(installJRE) then Result:=true; end; end else if(installJRE) then Result:=true; end; end. 解决方法
为什么在将InitializeSetup函数用作Check函数时多次调用它?
您正在使用InitializeSetup事件方法作为Check函数,这是导致多次调用此方法的原因.第一次初始化设置时(作为实际事件方法)和下一次检查确定时,是否应打开[Run]部分中的文件条目. 基本上,使用Check函数的事件方法是错误的.您甚至不应该手动调用它们,只需让安装程序应用程序触发它们即可.在你的情况下,而是创建一个函数,只检查是否安装了JRE并使用这样的功能进行检查. 如何获得Java SE Runtime Environment版本? 您不需要将设置作为64位运行.您只需从WOW注册表节点读取即可在64位Windows上获取64位JRE的版本.我试着用这样的东西: [Run] Filename: "{app}MyApp.exe"; Flags: nowait postinstall skipifsilent; Check: IsJREInstalled [Code] #define MinJRE "1.6" #define WebJRE "http://www.oracle.com/technetwork/java/javase/downloads/jre6downloads-1902815.html" function IsJREInstalled: Boolean; var JREVersion: string; begin // read JRE version Result := RegQueryStringValue(HKLM32,JREVersion); // if the previous reading failed and we're on 64-bit Windows,try to read // the JRE version from WOW node if not Result and IsWin64 then Result := RegQueryStringValue(HKLM64,JREVersion); // if the JRE version was read,check if it's at least the minimum one if Result then Result := CompareStr(JREVersion,'{#MinJRE}') >= 0; end; function InitializeSetup: Boolean; var ErrorCode: Integer; begin Result := True; // check if JRE is installed; if not,then... if not IsJREInstalled then begin // show a message box and let user to choose if they want to download JRE; // if so,go to its download site and exit setup; continue otherwise if MsgBox('Java is required. Do you want to download it now ?',MB_YESNO) = IDYES then begin Result := False; ShellExec('','{#WebJRE}',ErrorCode); end; end; end; (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |