PDA

View Full Version : MsiGetProperty and MsiSetProperty help



agshah
06-06-2017, 05:05 PM
Hi all,
I have an MSI InstallScript project.

In the install script, in function OnFirstUIBefore(), I am calling MsiSetProperty to set a property.
e.g.
MsiSetProperty(ISMSI_HANDLE, "PVALUE1", svPalue1);

From function OnFirstUIAfter(), I am calling PostInstallTasks() in which I invoke MsiGetProperty to retrieve
the property value but it is returning empty string.
e.g.
nvSize = 512;
MsiGetProperty (ISMSI_HANDLE, "PVALUE1", svGetPValue1, nvSize);

Can anyone please advise how to get this to work ?
If I call MsiGetProperty, right after MsiSetProperty, it returns the appropriate value that as set.

Are properties not at Global level? Meaning they can be accessed from any function after set ?

thanks in advance.

chad.petersen
06-08-2017, 11:45 AM
Properties that are in all UPPERCASE or a combination of UPPERCASE and NUMBERS, with the first character being Alpha - set the property as Global (public). Lowercase, mixed case and ones that start with numeric, are not Global (private).

MsiSetProperty(ISMSI_HANDLE, "PVALUE1", svPalue1);

what is svPalue1 (possible typo there as seems like you'd be using svPValue1, but whatever) set to for an initial value? And if you run your installer and have it write out a verbose log file do you see the PROPERTY named PVALUE1 being logged as changing values? You should see that in the log file. It should look something like this.

MSI (c) (EC:BC) [07:54:47:494]: PROPERTY CHANGE: Modifying PVALUE1 property. Its current value is '0'. Its new value: '1'.

Timing could be a factor, too. I don't use InstallScript MSI ever (NEVER) but I do use and recommend Basic MSI projects and you can still use InstallScript if you want to - I instead try to use C# DTF custom actions wherever possible so it is managed code and can be easily moved between Installshield and WiX as Cory mentioned in another post today.

Chad

ch_eng
09-18-2017, 10:46 AM
agshah,

We haven't used InstallScript MSI for a while, but I think anytime we needed to save values and use them in OnFirstUIAfter/etc, we had to global variables instead of MSI properties for the very reason you are seeing. MsiGetProperty seemed to only work within the block where it was set (OnFirstUIBefore).

HTH