cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
floriand
Level 3

Install Access database engine x86 or x64 conditionnaly

Hello,

I have a basic MSI project.
This project must install access database engine x86 or x64 depending on office version on the customer computer.

It is not possible to install it as a prerequisite because before install i need to know which office version is installed on the computer.
To detect office bitness, i have an installscript function that works well, but i don't know how / when to run the access database engine exe file.

Could you help me ?
Thanks in advance.
Labels (1)
0 Kudos
(7) Replies
MarkusLatz
Level 8

Why do you not modify the "access database engine" prerequisite (install condition) that it installs only if MS Office 32-Bit or 64-Bit is installed.

regards

Markus
0 Kudos
floriand
Level 3

Hello Markus and thank you for your answer.

I can't do that because our product has to be installed on any office version (office 2007, 2010, 2013, 2016, 365, 2019 desktop and store versions, x86 and x64 versions).
So i can't check a registry key in order to know which office version is installed (maybe it's possible, but i don't know how).

That's why i've tried to use an installscript function which allow to detect office bitness.
Here is my installscript :
////////////////////////////////////////////////////////////////////////////////
//
// IIIIIII SSSSSS
// II SS InstallShield (R)
// II SSSSSS (c) 1996-2002, InstallShield Software Corporation
// II SS All rights reserved.
// IIIIIII SSSSSS
//
//
// This template script provides the code necessary to build an entry-point
// function to be called in an InstallScript custom action.
//
//
// File Name: Setup.rul
//
// Description: InstallShield script
//
////////////////////////////////////////////////////////////////////////////////


// Include Ifx.h for built-in InstallScript function prototypes, for Windows
// Installer API function prototypes and constants, and to declare code for
// the OnBegin and OnEnd events.
#include "ifx.h"
// Include header file for built-in functions
#include "isrt.h"
// Include header file for MSI API functions and constants
#include "iswi.h"

// The keyword export identifies MyFunction() as an entry-point function.
// The argument it accepts must be a handle to the Installer database.
prototype LONG kernel32.GetBinaryTypeA (BYVAL STRING , BYREF INT );
export prototype SetOfficeBitnessProperty(HWND);

// To Do: Declare global variables, define constants, and prototype user-
// defined and DLL functions here.


// To Do: Create a custom action for this entry-point function:
// 1. Right-click on "Custom Actions" in the Sequences/Actions view.
// 2. Select "Custom Action Wizard" from the context menu.
// 3. Proceed through the wizard and give the custom action a unique name.
// 4. Select "Run InstallScript code" for the custom action type, and in
// the next panel select "MyFunction" (or the new name of the entry-
// point function) for the source.
// 5. Click Next, accepting the default selections until the wizard
// creates the custom action.
//
// Once you have made a custom action, you must execute it in your setup by
// inserting it into a sequence or making it the result of a dialog's
// control event.

///////////////////////////////////////////////////////////////////////////////
//
// Definition de la propriété OFFICEBITNESS (permet de savoir si excel est 32 ou 64 bits)
// http://codes-sources.commentcamarche.net/forum/affich-1611755-identifier-le-type-d-un-fichier-exe
//
///////////////////////////////////////////////////////////////////////////////
function SetOfficeBitnessProperty(hMSI)

NUMBER nBinaryType;

STRING svExcelFilePath;
NUMBER nvType, nvSize;

begin
try

RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);
RegDBGetKeyValueEx("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\excel.exe","",nvType,svExcelFilePath,nvSize);


//MessageBox("EXCELFILEPATH \n" + svExcelFilePath, SEVERE);

if GetBinaryTypeA(svExcelFilePath, nBinaryType)>0 then
if (nBinaryType=6) then
//64 bits
MsiSetProperty(hMSI, "ISOFFICE64", "1");
else
//32 bits
MsiSetProperty(hMSI, "ISOFFICE32", "1");
endif;

else
//Rechecherche si le chemin comporte x86 ou x64 (WindowsApp)
if StrFind(svExcelFilePath,"x86")<0 && StrFind(svExcelFilePath,"x64")<0 then
MessageBox("EXCEL FILE PATH \n" + "Impossible to determine Office bitness" , SEVERE);
return ERROR_INSTALL_FAILURE;
else
if StrFind(svExcelFilePath,"x86")<0 then
//64 bits
MsiSetProperty(hMSI, "ISOFFICE64", "1");
else
//32 bits
MsiSetProperty(hMSI, "ISOFFICE32", "1");
endif;
endif;
endif;
catch
MessageBox("SetOfficeBitnessProperty Error \n" + Err.Number + "\n" + Err.Description + "\n" + Err.LastDllError , SEVERE);
return ERROR_INSTALL_FAILURE;
endcatch;

end;



The problem with my current solution, is that i can't use the MSIProperties i have created in the prerequisite condition.
0 Kudos
MarkusLatz
Level 8

If you have a the premier edition you can use the suite project type.

What type of installer is the access database engine ? Also MSI ?

regards

Markus
0 Kudos
floriand
Level 3

It's an exe file, but i can extract the AceRedist.msi from it.

For the suite (i don't know it yet), does it means i need to redo my installer from scratch ?
0 Kudos
MarkusLatz
Level 8

No you can just include it.

A suite project is an installer type were you can include other installer packages and create custom actions to control the conditional install of the other packages.

So you have to create a suite project, then include your msi package and also your "access database engine's" (32-Bit and 64-Bit).

In the suite you can use installscript (i.e. your function you have written) to set a condition (suite property) for which version of your "access database engine" should be installed.

The suite is perfect for such a case, but you need the premier edition.

regards

Markus
0 Kudos
floriand
Level 3

I already have the premier edition, so i will test it.

Thank you very much Markus:)
0 Kudos
MarkusLatz
Level 8

You will love the suite project type !

regards

Markus
0 Kudos