Reputation: 2265
I have a strange issue. In my Inno setup script I must to check JRE. If the minimum JRE is not installed, it's triggered the installer of the bundled 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. So what is happening is that only 1 of this files is deleted "magically" after the bundled JRE is installed.
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.
So to prevent this, I want to install that file after installing the 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;
Upvotes: 3
Views: 4959
Reputation: 538
[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. 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.
Upvotes: 3