简体   繁体   English

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

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

I have a strange issue. 我有一个奇怪的问题。 In my Inno setup script I must to check JRE. 在我的Inno设置脚本中,我必须检查JRE。 If the minimum JRE is not installed, it's triggered the installer of the bundled JRE. 如果未安装最低JRE,则将触发捆绑JRE的安装程序。 This check is made after the files of my program have been installed in their destinations. 在将我的程序文件安装到目标位置后,进行此检查。

But I have 3 files that I must put them on JRE folder. 但是我有3个文件,必须将它们放在JRE文件夹中。 So what is happening is that only 1 of this files is deleted "magically" after the bundled JRE is installed. 因此,发生的是在安装捆绑的JRE之后,只有1个文件被“神奇地”删除了。

I mean: 我的意思是:

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

After installing JRE, win32com.dll and comm.jar are there, but javax.comm.properties no. 安装JRE后,在那里存在win32com.dll和comm.jar,但是没有javax.comm.properties

So to prevent this, I want to install that file after installing the JRE. 因此,为防止这种情况,我想在安装JRE之后安装该文件。 Is possible? 有可能吗 Or any other suggestion? 或其他建议?

Relevants parts of my script: 我脚本的相关部分:

[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;

[Files] section gives you a "dontcopy" flag, which means you can package your files, but copy them (or run them or whatever) whenever you want from [Code] section. [文件]部分为您提供了一个“ dontcopy”标志,这意味着您可以打包文件,但是可以随时从[代码]部分中复制文件(或运行文件或执行其他操作)。 Like this: 像这样:

[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;

Use the "PostInstall" stage to extract your files and copy them to JRE folder. 使用“ PostInstall”阶段解压缩文件并将其复制到JRE文件夹。

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

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