Invalid prototype when using a Check function - inno-setup

I'm new to InnoSetup as I am experimenting with various installers.
I created my first script using Inno Script Studio and the built in wizards. So far so good. Now I want to get it to detect if .Net 4.5 is installed and if it isn't then install it. So, I looked all over the web and on here and I came across this solution, however when I copy and paste the code into my script I get the following error when compiling.
Compiling [Code] section
Compiler Error!
Line 54: Column 10: Invalid prototype for 'IsDotNetDetected'
and Line 54 in my script is this
function IsDotNetDetected(version: string; service: cardinal): boolean;
anyone know what the error means and why I am getting it?
Here's my full script:
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
#define MyAppName "AVO Log"
#define MyAppVersion "0.1.0.1"
#define MyAppPublisher "NA"
#define MyAppExeName "AVO Log.exe"
[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={{9476587F-A670-4E17-B8EA-A6FABB345968}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
DefaultDirName={pf}\{#MyAppName}
DefaultGroupName={#MyAppName}
AllowNoIcons=yes
OutputBaseFilename=setup
Compression=lzma
SolidCompression=yes
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
[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
[Files]
Source: "G:\Common\Gareths Apps\dotNetFx45_Full_x86_x64.exe"; DestDir: {tmp}; Flags: deleteafterinstall;
Source: "C:\Visual Studio 2010\Projects\AVO Log\AVO Log\bin\Release\AVO Log.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\Visual Studio 2010\Projects\AVO Log\AVO Log\bin\Release\GalaSoft.MvvmLight.Extras.WPF45.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\Visual Studio 2010\Projects\AVO Log\AVO Log\bin\Release\GalaSoft.MvvmLight.WPF45.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\Visual Studio 2010\Projects\AVO Log\AVO Log\bin\Release\GalaSoft.MvvmLight.WPF45.xml"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\Visual Studio 2010\Projects\AVO Log\AVO Log\bin\Release\Microsoft.Expression.Interactions.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\Visual Studio 2010\Projects\AVO Log\AVO Log\bin\Release\Microsoft.Practices.ServiceLocation.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\Visual Studio 2010\Projects\AVO Log\AVO Log\bin\Release\System.Windows.Interactivity.dll"; DestDir: "{app}"; Flags: ignoreversion
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
[Icons]
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"
Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: quicklaunchicon
[Run]
Filename: "{tmp}\dotNetFx45_Full_x86_x64.exe"; Check: IsDotNetDetected('v4.5',0)
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
[Code]
function IsDotNetDetected(version: string; service: cardinal): boolean;
// Indicates whether the specified version and service pack of the .NET Framework is installed.
//
// version -- Specify one of these strings for the required .NET Framework version:
// 'v1.1.4322' .NET Framework 1.1
// 'v2.0.50727' .NET Framework 2.0
// 'v3.0' .NET Framework 3.0
// 'v3.5' .NET Framework 3.5
// 'v4\Client' .NET Framework 4.0 Client Profile
// 'v4\Full' .NET Framework 4.0 Full Installation
// 'v4.5' .NET Framework 4.5
//
// service -- Specify any non-negative integer for the required service pack level:
// 0 No service packs required
// 1, 2, etc. Service pack 1, 2, etc. required
var
key: string;
install, release, serviceCount: cardinal;
check45, success: boolean;
begin
// .NET 4.5 installs as update to .NET 4.0 Full
if version = 'v4.5' then begin
version := 'v4\Full';
check45 := true;
end else
check45 := false;
// installation key group for all .NET versions
key := 'SOFTWARE\Microsoft\NET Framework Setup\NDP\' + version;
// .NET 3.0 uses value InstallSuccess in subkey Setup
if Pos('v3.0', version) = 1 then begin
success := RegQueryDWordValue(HKLM, key + '\Setup', 'InstallSuccess', install);
end else begin
success := RegQueryDWordValue(HKLM, key, 'Install', install);
end;
// .NET 4.0/4.5 uses value Servicing instead of SP
if Pos('v4', version) = 1 then begin
success := success and RegQueryDWordValue(HKLM, key, 'Servicing', serviceCount);
end else begin
success := success and RegQueryDWordValue(HKLM, key, 'SP', serviceCount);
end;
// .NET 4.5 uses additional value Release
if check45 then begin
success := success and RegQueryDWordValue(HKLM, key, 'Release', release);
success := success and (release >= 378389);
end;
result := success and (install = 1) and (serviceCount >= service);
end;

My psychic powers tell me that you're trying to use this function as a check: parameter. As functions used with check: parameters must have a specific prototype, the compiler is failing.
Try using this stub function:
function CheckIsDotNetDetected(): boolean;
begin
result := IsDotNetDetected('v4\Client', 0);
end;

Example of check for .Net 4 for 32bit systems
function NET4032(): Boolean;
var
InstallCheck : Cardinal;
begin
RegQueryDWordValue(HKLM32, 'SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full',
'Install', InstallCheck);
if InstallCheck = $1 then
Result := false
else
Result := true;
end;

Related

Inno Setup remove specific reg key after uninstall

I try to remove a registry key after uninstalling it in Windows, but I couldn't get it working somehow. I tried everything which was listed here: Inno Setup: Removing a problematic registry key left by another program
I checked different docs of Inno Setup:
https://jrsoftware.org/ishelp/index.php?topic=uninstalldeletesection
https://jrsoftware.org/ishelp/index.php?topic=isxfunc_regdeletekeyincludingsubkeys
https://jrsoftware.org/ishelp/index.php?topic=registrysection
https://jrsoftware.org/ishelp/index.php?topic=isxfunc_regdeletevalue
I ended up with this:
; Basic setup for a JavaFX application
#define AppName "Practicumopdracht OOP2"
#define AppVersion "1.0.0"
#define AppPublisher "Remzi Cavdar"
#define AppURL "https://twitter.com/remzicavdar"
#define AppExeName "practicumopdracht.jar"
#define AppExeDir "C:\Users\Remzi\Projects\student-1\out\artifacts\practicumopdracht_jar"
#define AppIcon "app.ico"
#define ProjectDir "C:\Users\Remzi\Projects\JavaFX-Setup"
[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={{DD7E7C3F-F4AC-4D76-8626-95019C15E111}
AppName={#AppName}
AppVersion={#AppVersion}
VersionInfoVersion=1.0.0.0
VersionInfoCopyright={#AppPublisher} - ict#remzi.info
AppVerName={#AppName}
AppPublisher={#AppPublisher}
AppPublisherURL={#AppURL}
AppSupportURL={#AppURL}
AppUpdatesURL={#AppURL}
DefaultDirName={localappdata}\Remzi Cavdar\{#AppName}
DisableProgramGroupPage=yes
PrivilegesRequired=lowest
OutputBaseFilename=Setup-practicumopdracht
Compression=lzma
SolidCompression=yes
WizardStyle=modern
UninstallDisplayName={#AppName}
UninstallDisplayIcon={app}\{#AppIcon}
MinVersion=10.0.10240
[Languages]
Name: "dutch"; MessagesFile: "compiler:Languages\Dutch.isl"
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
[Files]
Source: "{#AppExeDir}\{#AppExeName}"; DestDir: "{app}"; Flags: ignoreversion
Source: "{#ProjectDir}\{#AppIcon}"; DestDir: "{app}"; Flags: ignoreversion
Source: "{#ProjectDir}\Input\OpenJDK19U-jre_x64_windows_hotspot_19_36.msi"; DestDir: "{tmp}"; AfterInstall: RunJavaInstaller
[Icons]
Name: "{autoprograms}\{#AppName}"; Filename: "{app}\{#AppExeName}"; IconFilename: "{app}\{#AppIcon}"
Name: "{autodesktop}\{#AppName}"; Filename: "{app}\{#AppExeName}"; IconFilename: "{app}\{#AppIcon}"; Tasks: desktopicon
[Registry]
Root: HKCU; Subkey: "Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Compatibility Assistant\Store"; ValueType: binary; ValueName: "{app}\unins000.exe"; Flags: dontcreatekey uninsdeletevalue
[Run]
Filename: "{app}\{#AppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(AppName, '&', '&&')}}"; Flags: shellexec postinstall skipifsilent
[UninstallDelete]
Type: filesandordirs; Name: "{localappdata}\Remzi Cavdar"
[Code]
procedure RunJavaInstaller;
var
ErrorCode: Integer;
begin
if not ShellExec('', 'msiexec.exe', ExpandConstant('/i "{tmp}\OpenJDK19U-jre_x64_windows_hotspot_19_36.msi" ADDLOCAL=FeatureMain,FeatureEnvironment,FeatureJarFileRunWith,FeatureJavaHome,FeatureOracleJavaSoft /qb'), '', SW_SHOWNORMAL, ewWaitUntilTerminated, ErrorCode)
then
MsgBox('Java JRE installer failed to run!' + #13#10 + ' ' + SysErrorMessage(ErrorCode), mbError, MB_OK);
end;
This is what I'm trying to remove after uninstall:
I found a solution to my registry question. I needed to check for both 32-bit and 64-bit.
[Registry]
Root: HKCU; Subkey: "Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Compatibility Assistant\Store"; ValueType: binary; ValueName: "{app}\unins000.exe"; Flags: dontcreatekey uninsdeletevalue
Root: HKCU64; Subkey: "Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Compatibility Assistant\Store"; ValueType: binary; ValueName: "{app}\unins000.exe"; Flags: dontcreatekey uninsdeletevalue; Check: IsWin64
I found the answer here: Writing 32/64-bit specific registry key in Inno Setup and https://jrsoftware.org/ishelp/index.php?topic=registrysection also mention this with HKLM64 example, but I read things to fast to notice it.

Unpack SFX file using Inno Setup

I'm trying to run Inno Setup to automatically extract my SFX file without having to run extract manually. Is there any way? I leave my script below.
Is there also a way to make Inno Setup extract the SFX in the Myprogramfolder created by the installer?
I have compressed the SFX file using Winrar.
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
#define MyAppName "Program2019"
#define MyAppVersion "1.0"
#define MyAppPublisher "Myappname."
#define MyAppURL "/"
[Setup]
WizardImageFile=C:\Users\Administrator\Desktop\Cover.bmp
; NOTE: The value of AppId uniquely identifies this application.
AppID={{31D336CF-0483-4A76-00000000000000000}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
DefaultDirName={pf}\Myprogram2019
DefaultGroupName={#MyAppName}
LicenseFile=C:\Users\Administrator\Desktop\Program2019\readme.txt
OutputDir=C:\Users\Administrator\Desktop\Program2019\Myprografolder
OutputBaseFilename=setup
SetupIconFile=C:\Users\Administrator\Desktop\Program2019\Myprogram\icon.ico
Compression=none
SolidCompression=true
InternalCompressLevel=Fast
[Languages]
Name: "english"; MessagesFile: "compiler:Languages\English.isl"
Name: "spanish"; MessagesFile: "compiler:Languages\Spanish.isl"
[Files]
Source: "C:\Program Files (x86)\Myprogramfolder\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "C:\Users\Administrator\Desktop\Program2019\Unpack\Evilpack.exe"; DestDir: "{tmp}"; Flags: deleteafterinstall
Source: "C:\Users\Administrator\Desktop\Program2019\languages\spanish\*"; DestDir: "{app}\game"; Languages: spanish; Flags: ignoreversion recursesubdirs createallsubdirs
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
[Run]
Filename: "{tmp}\Evilpack.exe"; Parameters: "{tmp}\ZipFile.ZIP -d C:\TargetDir"
[Icons]
Name: "{group}\{cm:ProgramOnTheWeb,{#MyAppName}}"; Filename: "{#MyAppURL}"
Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"
Name: "{commondesktop}\Myprogram2019"; Filename: "{app}\mypro.exe"; IconFilename: {app}\icon.ico; \
AfterInstall: SetElevationBit('{commondesktop}\Myprogram.lnk')
[Code]
{ RedesignWizardFormBegin } // Don't remove this line!
// Don't modify this section. It is generated automatically.
procedure RedesignWizardForm;
begin
{ ReservationBegin }
// This part is for you. Add your specialized code here.
{ ReservationEnd }
end;
[Messages]
BeveledLabel=Myapp
Is very easy unpack in silent way SFX, setup to silent from the menu option ADVANCED, then SFX options in winrar.
That is all!!
Finally
[Files]
Source: "C:\pathtofile\yoursfx.exe"; DestDir: "C:\Program Files\";Flags: ignoreversion
[Run]
Filename: "C:\Program Files\yoursfx.exe"; StatusMsg: "Your MSG"; Flags: runascurrentuser
[Code]
procedure CurStepChanged(CurStep: TSetupStep);
begin
if CurStep = ssDone then
begin;
DeleteFile(ExpandConstant('C:\Program Files\yoursfx.exe'));
begin
// user clicked Yes
end;
end;
end;

How to selectively create a directory, copy files and run a batch file in InnoSetup [duplicate]

Alternatively is it possible to manually update the built in progress bar?
Basically I have 2 MSIs included and using Inno Setup as a bootstrapper, and depending on user input one or both of the MSIs are to be installed. I have something working using Exec statements in CurStepChanged but it doesn't update the progress bar as the files are extracted and it looks like the installer is stalled. I guess the end result is I want some progress bar updates while the files are extracted to the temp folder. The following is my current code:
procedure CurStepChanged(CurStep: TSetupStep);
var
ResultCode: Integer;
begin
if(CurStep = ssInstall) then begin
if(InstallServer) then begin
ExtractTemporaryFile('ServerSetup.msi');
Exec('msiexec',ExpandConstant('/i "{tmp}\ServerSetup.msi" /qb INSTALLDIR="{code:GetInstallPath}\Server\" ALLUSERS=2'),'', SW_SHOW, ewWaitUntilTerminated, ResultCode);
end;
if(InstallClient) then begin
ExtractTemporaryFile('ClientSetup.msi');
Exec('msiexec',ExpandConstant('/i "{tmp}\ClientSetup.msi" /qb INSTALLDIR="{code:GetInstallPath}\Client\" ALLUSERS=2'),'', SW_SHOW, ewWaitUntilTerminated, ResultCode);
end;
end;
end;
Why not simply try something like this:
[Files]
Source: ClientSetup.msi; DestDir: {tmp}; Flags: deleteafterinstall; Components: Client
Source: ServerSetup.msi; DestDir: {tmp}; Flags: deleteafterinstall; Components: Server
[Run]
Filename: msiexec.exe; Parameters: /i "{tmp}\ClientSetup.msi" /qb INSTALLDIR="{code:GetInstallPath}\Client\" ALLUSERS=2; WorkingDir: {tmp}; StatusMsg: Installing client; Components: Client
Filename: msiexec.exe; Parameters: /i "{tmp}\ServerSetup.msi" /qb INSTALLDIR="{code:GetInstallPath}\Server\" ALLUSERS=2; WorkingDir: {tmp}; StatusMsg: Installing server; Components: Server
[Components]
Name: Client; Description: Client Installation
Name: Server; Description: Server Installation
Of course you don't necessarily have to use Components. You did not write how you decide which installer to run. If you need more complex logic you could also use Check functions as in:
[Files]
Source: ClientSetup.msi; DestDir: {tmp}; Flags: deleteafterinstall; Check: CheckClient
Source: ServerSetup.msi; DestDir: {tmp}; Flags: deleteafterinstall; Check: CheckServer
[Run]
Filename: msiexec.exe; Parameters: /i "{tmp}\ClientSetup.msi" /qb INSTALLDIR="{code:GetInstallPath}\Client\" ALLUSERS=2; WorkingDir: {tmp}; StatusMsg: Installing client; Check: CheckClient
Filename: msiexec.exe; Parameters: /i "{tmp}\ServerSetup.msi" /qb INSTALLDIR="{code:GetInstallPath}\Server\" ALLUSERS=2; WorkingDir: {tmp}; StatusMsg: Installing server; Check: CheckServer
[Code]
function CheckClient: Boolean;
begin
Result := WhateverCondition;
end;
function CheckServer: Boolean;
begin
Result := WhateverOtherCondition;
end;

I wanted to add my setup at user/My Documents for every user using the inno setup but its not working for me

I wanted to add my setup at user/My Documents for every user using the inno setup but its not working for me.
Here i provide u my iis file.
Thanks in advance.
Please help me out.
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
#define MyAppName "Testing"
#define MyAppVersion "1.0"
#define MyAppPublisher "Test"
#define MyAppURL "http://www.example.com/"
#define MyAppExeName "testing.exe"
[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}\test
DefaultDirName={code:DefDirRoot}\test
DisableDirPage=yes
DefaultGroupName=test
DisableProgramGroupPage=yes
AllowNoIcons=yes
LicenseFile=C:\Users\abc\Desktop\final product\licence.txt
OutputDir=C:\Users\abc\Documents\test
OutputBaseFilename=VL-PI Setup
SetupIconFile=C:\Users\abc\Downloads\clientcommentsveryimp\CORRECTIONS_TO_INSTALLER_BUGS\CORRECTIONS_TO_INSTALLER_BUGS\Icon\icon.ico
Compression=lzma
SolidCompression=yes
PrivilegesRequired=none
[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"
[Files]
Source: "C:\test work\agriculture project requirments\jre-6u2-windows-i586-p.exe"; DestDir: "{tmp}"; Flags: deleteafterinstall;
Source: "D:\final product\30-01-2013\test.exe"; DestDir: "{app}"; Flags: ignoreversion;
Source: "C:\Users\test\Desktop\final product\Graphics\*"; DestDir: "{app}\Graphics"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "C:\Users\test\Desktop\final product\lib\*"; DestDir: "{app}\lib"; Flags: ignoreversion recursesubdirs createallsubdirs
[Icons]
Name: "{group}\VL-PI"; Filename: "{app}\{#MyAppExeName}"
Name: "{group}\{cm:uninstallProgram,VL-PI}"; Filename: "{uninstallexe}"
Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}";
Tasks: quicklaunchicon
[Run]
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}";check:InitializeSetup; Flags: nowait postinstall skipifsilent
[Code]
function Install_JavaFrameWork() : Boolean;
var
hWnd: Integer;
ResultCode: Integer;
dotnetRedistPath: string;
outVar : string;
begin
dotnetRedistPath:= ExpandConstant('{tmp}\jre-6u2-windows-i586-p.exe');
try
if Exec(dotnetRedistPath,'', '', SW_SHOW, ewWaitUntilTerminated, ResultCode) then
begin
// ResultCode contains the exit code
case ResultCode of
// 1641 The requested operation completed successfully. The system will be restarted so the changes can take effect.
// 3010 The requested operation is successful. Changes will not be effective until the system is rebooted.
1641:
begin
Result := true;
end
3010, 0:
begin
Result := false;
end else // -> case default
begin
Result := true;
end
end;
end else
begin
//handle failure if necessary; ResultCode contains the error code
Result := false;
end;
except
ShowExceptionMessage;
end;
end;
function InitializeSetup(): Boolean;
var
ErrorCode: Integer;
JavaInstalled : Boolean;
Result1 : Boolean;
Versions: TArrayOfString;
I: Integer;
begin
if RegGetSubkeyNames(HKLM, 'SOFTWARE\JavaSoft\Java Runtime Environment', Versions) then
begin
for I := 0 to GetArrayLength(Versions)-1 do
if JavaInstalled = true then
begin
//do nothing
end else
begin
if ( Versions[I][2]='.' ) and ( ( StrToInt(Versions[I][1]) > 1 ) or ( ( StrToInt(Versions[I][1]) = 1 ) and (
StrToInt(Versions[I][3]) >= 6 ) ) ) then
begin
JavaInstalled := true;
end else
begin
JavaInstalled := false;
end;
end;
end else
begin
JavaInstalled := false;
end;
//JavaInstalled := RegKeyExists(HKLM,'SOFTWARE\JavaSoft\Java Runtime Environment\1.9');
if JavaInstalled then begin
Result := true;
end
else begin
if FileExists(ExpandConstant('{tmp}\jre-6u2-windows-i586-p.exe')) then
begin
Log('File exists');
Result1 := MsgBox('This program requires Java Runtime Environment version 1.6 or newer.Do you want to install it now?',
mbConfirmation, MB_YESNO) = idYes;
if Result1 = false then begin
Result:=true;
end
else begin
Install_JavaFrameWork;
Result:=true;
end;
end else
begin
Result:=true;
end;
end;
end;
An admin setup should never try and write to the user's profiles as they aren't guaranteed to be the user you expect or even accessable from that machine.
You're currently using PrivilegesRequired=none so it will not switch user, but that will stop you from installing Java for some users.
You should use PrivilegesRequired=admin for normal installations or PrivilegesRequired=lowest for user specific installations.

Problem with checking the Windows version from Inno Setup

My program installs a driver, which has different versions compiled for XP, Win2003, Vista/Win2008, and Win7. I use pascal functions to check which is the OS, and install the corresponding DLL.
On some users' systems no DLL is installed, which means all the functions have returned false. This should not happen so long as the OS's major version is 5 or 6.
Can anyone tell me if there is something wrong with the code I use?
[Code]
function UseDriverForWindows7(): Boolean;
var
Version: TWindowsVersion;
begin
GetWindowsVersionEx(Version);
// Windows 7 version is 6.1 (workstation)
if (Version.Major = 6) and
(Version.Minor = 1) and
(Version.ProductType = VER_NT_WORKSTATION)
then
Result := True
else
Result := False;
end;
function UseDriverForWindowsVistaAndWindows2008(): Boolean;
var
Version: TWindowsVersion;
begin
GetWindowsVersionEx(Version);
// Anything with major version 6 where we won't use Windows 7 driver
if (Version.Major = 6) and
(not UseDriverForWindows7)
then
Result := True
else
Result := False;
end;
function UseDriverForWindows2003(): Boolean;
var
Version: TWindowsVersion;
begin
GetWindowsVersionEx(Version);
// Windows 2003 version is 5.2 (server)
if (Version.Major = 5) and
(Version.Minor = 2) and
(Version.ProductType <> VER_NT_WORKSTATION)
then
Result := True
else
Result := False;
end;
function UseDriverForWindowsXP(): Boolean;
var
Version: TWindowsVersion;
begin
GetWindowsVersionEx(Version);
// Anything with major version 5 where we won't use Windows 2003 driver
if (Version.Major = 5) and
(not UseDriverForWindows2003)
then
Result := True
else
Result := False;
end;
[Files]
Source: "mydrv-xp-x86.dll"; DestDir: {app}; DestName: mydrv.dll; Check: not IsWin64 and UseDriverForWindowsXP; Flags: ignoreversion
Source: "mydrv-2003-x86.dll"; DestDir: {app}; DestName: mydrv.dll; Check: not IsWin64 and UseDriverForWindows2003; Flags: ignoreversion
Source: "mydrv-vista-x86.dll"; DestDir: {app}; DestName: mydrv.dll; Check: not IsWin64 and UseDriverForWindowsVistaAndWindows2008; Flags: ignoreversion
Source: "mydrv-win7-x86.dll"; DestDir: {app}; DestName: mydrv.dll; Check: not IsWin64 and UseDriverForWindows7; Flags: ignoreversion
Source: "mydrv-xp-x64.dll"; DestDir: {app}; DestName: mydrv.dll; Check: IsWin64 and UseDriverForWindows2003; Flags: ignoreversion
Source: "mydrv-vista-x64.dll"; DestDir: {app}; DestName: mydrv.dll; Check: IsWin64 and UseDriverForWindowsVistaAndWindows2008; Flags: ignoreversion
Source: "mydrv-win7-x64.dll"; DestDir: {app}; DestName: mydrv.dll; Check: IsWin64 and UseDriverForWindows7; Flags: ignoreversion
You should use the common parameters MinVersion and OnlyBelowVersion in conjunction with the function IsWin64.
Update
To distinguish between workstation and server versions you can use the GetWindowsVersionEx function which is integrated in Inno Setup.

Resources