cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
SMadden
Level 6

MsiOpenPackage in pure InstallScript crashes Setup.exe

Hi,

I have a pure InstallScript project that works as a wrapper to run several different installers, some MSI, some not. some 3rd Party and some of them ours.

In each OnInstalled() event that runs an MSI we have code that checks to see if the MSI is already installed or not. We use MsiOpenPackage to open the package and get it's ProductCode. After that we check with MsiQueryProductState if the Product is already installed or not.

Everything works fine until the first MergeModule is installed, after that a call to MsiOpenPackage will crash the Setup.exe.

To rule out that the MergeModules themselves introduce this bug, I removed them and added the ATL3.0 MSM. Same result.

When I remove all MergeModules from the Installer, all MsiOpenPackage calls succeed.

Any ideas for a workaround? Does anyone else see this bug?

It seems like a problem of the InstallShield MergeModule holder to me.

I'm using InstallShield 2009 Premier Edition SP2/SAB SP2. Pure InstallScript project.

Thanks,
Sandra
Labels (1)
0 Kudos
(2) Replies
Holger_G
Level 10

Sandra,

here is some simple code that works for me even if a merge module has been installed before. Maybe it works for you too.


function NewFeature1_Installed()
STRING szQuery, szProductCode;
OBJECT oMSI, oDatabase, oView, oRec;
begin
set oMSI = CreateObject("WindowsInstaller.Installer");
if (IsObject(oMSI)) then
try
set oDatabase = oMSI.OpenDatabase(TARGETDIR ^ "orca.msi", 0); //0=MSIDBOPEN_READONLY
if (IsObject(oDatabase)) then
szQuery = "select `Value` from `Property` where `Property` = 'ProductCode'";
set oView = oDatabase.OpenView(szQuery);
oView.Execute;
set oRec = oView.Fetch;
szProductCode = oRec.StringData(1);
SprintfBox (INFORMATION, "", "ProductCode: %s", szProductCode);
set oRec = NOTHING;
set oDatabase = NOTHING;
set oDatabase = NOTHING;
set oView = NOTHING;
endif;
catch
SprintfBox (WARNING, "OpenDatabase", "Database failed");
endcatch;
endif;
end;


Holger 🙂
0 Kudos
SMadden
Level 6

yep. works like a charm. Thanks Holger!

Sandra
0 Kudos