2014-01-19 166 views
2

我有一個奇怪的問題。在我的Inno設置腳本中,我必須檢查JRE。如果未安裝最低JRE,則會觸發捆綁JRE的安裝程序。此檢查是在我的程序的文件已安裝到目的地後進行的。Inno Setup:安裝後如何安裝文件?

但我有3個文件,我必須把它們放在JRE文件夾中。所以發生的情況是,在安裝捆綁的JRE之後,只有一個這樣的文件被「神奇地」刪除。

我的意思是:

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; 
+0

如何安裝捆綁的JRE?你是否在腳本的[Run]部分運行'jre-7-windows- .exe'?你是否刪除腳本中的任何文件?向我們展示腳本的相關部分,請... – TLama

+0

在momeent我沒有腳本,但是,我在[Run]部分觸發了安裝程序,然後使用自定義代碼檢查JRE。我不刪除任何文件。 – anat0lius

+0

添加了我的腳本代碼。 – anat0lius

回答

3

[文件]部分爲您提供了一個「dontcopy」標誌,這意味着你可以打包你的文件,但將它們複製(或運行它們或其他)每當你想來自[Code]部分。像這樣:

[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文件夾。

相關問題