繁体   English   中英

Inno Setup:安装后如何安装文件?

[英]Inno Setup: How to install a file after install?

我有一个奇怪的问题。 在我的Inno设置脚本中,我必须检查JRE。 如果未安装最低JRE,则将触发捆绑JRE的安装程序。 在将我的程序文件安装到目标位置后,进行此检查。

但是我有3个文件,必须将它们放在JRE文件夹中。 因此,发生的是在安装捆绑的JRE之后,只有1个文件被“神奇地”删除了。

我的意思是:

win32com.dll          -> {pf}/Java/jre7/bin
comm.jar              -> {pf}/Java/jre7/lib/ext
javax.comm.properties -> {pf}/Java/jre7/lib

安装JRE后,在那里存在win32com.dll和comm.jar,但是没有javax.comm.properties

因此,为防止这种情况,我想在安装JRE之后安装该文件。 有可能吗 或其他建议?

我脚本的相关部分:

[Run]  
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
Filename: "{app}\jre-7u45-windows-i586.exe"; WorkingDir: {app}; StatusMsg: Checking Java Runtime Environment... Please Wait...;Check:JREVerifyInstall

[Code]
#define MinJRE "1.7"

Function JREVerifyInstall:Boolean;
var
  JREVersion: string;
begin
if (RegValueExists(HKEY_LOCAL_MACHINE, 'SOFTWARE\JavaSoft\Java Runtime Environment','CurrentVersion')) then 
  begin
  Result := RegQueryStringValue(HKEY_LOCAL_MACHINE, 'Software\JavaSoft\Java Runtime Environment', 'CurrentVersion', JREVersion);
  if Result then
      Result := CompareStr(JREVersion, '{#MinJRE}') <> 0; 
  end
else
  Result := true;

end;

[文件]部分为您提供了一个“ dontcopy”标志,这意味着您可以打包文件,但是可以随时从[代码]部分中复制文件(或运行文件或执行其他操作)。 像这样:

[Files]
Source: "a.txt"; Flags: dontcopy

[Code]
procedure CurStepChanged(CurStep: TSetupStep);
begin
    if CurStep = ssPostInstall then begin
      //This will actually extract your file to setup's temporary directory. 
      //If you don't do this, the file is skipped
      //The temporary directory is deleted after setup ends.
      ExtractTemporaryFile('a.txt');

      FileCopy(ExpandConstant('{tmp}\a.txt'), 'c:\temp\a.txt', False);
    end;
end;

使用“ PostInstall”阶段解压缩文件并将其复制到JRE文件夹。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM