i am currently trying to create a custom script for installing a program. i need to check if the runtime engine of crystal reports 13 is installed, if not then installed. this is what i am trying to do:
//check crystalReports
if (not RegKeyExists(HKLM, 'Software\SAP BusinessObjects\Crystal Reports for .NET Framework 4.0\Crystal Reports')) then
begin
crystalReportsNeeded := true;
if (not IsAdminLoggedOn()) then begin
MsgBox('GasSoft needs the Crystal Reports to be installed by an Administrator', mbInformation, MB_OK);
Result := false;
end
else
begin
memoDependenciesNeeded := memoDependenciesNeeded + ' Crystal Reports' #13;
SetIniString('install', 'dotnetRedist', dotnetRedistPath, ExpandConstant('{tmp}\dep.ini'));
end;
end else
begin
MsgBox('installed cr', mbInformation, MB_OK);
end;
so this is updating a var caleed crystallreportsneeded to true or false. this variable will be use on the check function of the file. i have check on the control panel that the runtime engine is installed, but every time i run the setup it tries to installed the file. What am i missing., is the regkey correct?
After a bit of search i found out that some people instead of searching the folder goes to uninstal folder in HKLM->Windowns->CurrentVersion->Unistall.. in my case there is a register of the sap component with a product code but this does create a problem, if by any mean i update the version of the sap crystal reports through the web, and then try to run the setup script it creates a problem where the current version installed is newer than the one i am currently trying to install...
14/10/2014 - Update... So i still cant check if the program is installed or not, i have also tried doing this
sUnInstPath := ExpandConstant('Software\Microsoft\Windows\CurrentVersion\Uninstall\{{1D8E6291-B0D5-35EC-8441-6616F567A0F7}}'); //Your App GUID/ID
sUnInstallString := '';
if RegQueryStringValue(HKLM, sUnInstPath, 'InstallDate', sUnInstallString) then
MsgBox('Exists... ' , mbInformation, MB_OK);
this 1D8E6291-B0D5-35EC-8441-6616F567A0F7 refers to app id in this case vcc+... and i also tried this
RegQueryDWordValue(HKLM, 'Software\Microsoft\Windows\CurrentVersion\Uninstall\{{1D8E6291-B0D5-35EC-8441-6616F567A0F7}}', 'Version', version);
it doesnt show the message,, for the moment there are 2 options, one always install, and two check if file exists with FileExists..so any help is appreciated..
Update - 15/10/2014 So i think i have found a workaround, i dont think that this a solution because i cant explain some of the things that are happening.. This workaround is only in the case you are using Crystal reports and still needs to be tested in a 32 bits machine,but i almost certain that it will also work. for the moment i am testing on 64bits machine with win 8.1,and i will test the scripts in a 32bits also.
So i need to separate the scripts one for x32 and other for x64. the diference was in the [setup] parameters, if setup is for 64 bits it needs these 2 lines:
ArchitecturesInstallIn64BitMode=x64
ArchitecturesAllowed=x64
these are the description:
ArchitecturesAllowed=x64 specifies that Setup cannot run on anything but x64. ArchitecturesInstallIn64BitMode=x64" requests that the install be done in "64-bit mode" on x64, meaning it should use the native 64-bit Program Files directory and the 64-bit view of the registry.
so i am currently stating that the script can only work on 64bits, and that the folder system is 64bits..
after adding these 2 lines the code for finding the key executes with success. the code for trying to find if the key exists is below..
sKey:=ExpandConstant('SOFTWARE\SAP BusinessObjects\Crystal Reports for .NET Framework 4.0\Crystal Reports');
MsgBox('Before if' , mbInformation, MB_OK); //trying to test if is reaching this statement..
if( RegKeyExists(HKLM, sUnInstPath)) then begin
MsgBox('key found' , mbInformation, MB_OK);
this only happens if you need to install the crystal reports runtime engine 64bits. on my script i am checking for the existence of sql server are installed, if not exists then install.
if you have installed crruntime engine 32bits in a 64bits machine then you dont need to add the lines.. the path of the key is now SOFTWARE\Wow6432Node\SAP BusinessObjects\Crystal Reports for .NET Framework 4.0\Crystal Reports i dont know if it is possible to add an if condition on the [Setup] that state that the 2lines of code are added if i am running the setup in a 64 bits machine..
if there are new updates to the situation i will update the post... Thanks in advance..
So thanks to user TLama, that explained how inno setup works on a 64bits machine.. here is the code for checking if crystal reports runtime engine 13 is installed:
[Code]
const
CrystalReportsKey = 'SOFTWARE\SAP BusinessObjects\Crystal Reports for .NET Framework
4.0\Crystal Reports';
var
crNeeded:boolean;
memoDependenciesNeeded: string;
function InitializeSetup(): Boolean;
begin
if (IsWin64 and (not RegKeyExists(HKLM64, CrystalReportsKey) or not RegKeyExists(HKLM32,CrystalReportsKey))) or
(not IsWin64 and not RegKeyExists(HKLM, CrystalReportsKey))) then begin
crNeeded:=true;
memoDependenciesNeeded := memoDependenciesNeeded + ' Crystal Reports 13' #13;
end;
end;
so i am checking if i am running on a 32 bits windows or a 64 bits windows.
if running on a 64bits windows i am checking the existence of a regkey on the HKLM 64bits view, if the key exists the var crNeeded maintains the initially value of false, if not then we need to check the 32 bits view of regkeys just in case if Crystal Reports installed was a 32 bits executable. if still no regkey then we set the variable crNeeded to true stating that we need to install crystal reports.
i changed the if clause from ProcessorArchitecture=paX64 to IsWin64 , because the ProcessorArchitecture is checking if the processor is 64bits or 32 bits, and this can cause an exception if there is a 32bits windows on a 64bits machine.
The variable crNeeded will be used on a check function of the file, i mean it will only install if we this variable is true. Once again thanks again to user TLama for all the help... Thanks..
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With