cancel
Showing results for 
Search instead for 
Did you mean: 
agshah
Occasional contributor

MsiGetProperty and MsiSetProperty help

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.
Labels (1)
0 Kudos
4 Replies
chad_petersen
Flexera beginner

Re: MsiGetProperty and MsiSetProperty help

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
0 Kudos
ch_eng
Flexera beginner

Re: MsiGetProperty and MsiSetProperty help

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
0 Kudos
AceBear
Flexera beginner

Re: MsiGetProperty and MsiSetProperty help

when you say "we had to global variables instead of MSI properties..", what do you mean by global variables? how to create global variables? I am having the same problem like this post. I am trying to find a solution for creating a "global flag" and use this flag in InstallScript.

0 Kudos
Highlighted
AceBear
Flexera beginner

Re: MsiGetProperty and MsiSetProperty help

Agshah,

Your observation is correct. I just tested the behavior of setting and retrieving  a public property and I see the same behavior. 

However, the global property (the flag) can be set in function OnFirstUIBefore() and be used in Custom Actions. In my project, I set a global property (a flag) a new value in the OnFirstUIBefore(), then I use this flag as the condition to drive the behavior of a Custom Action. This approach worked for me. There are quite a lot of types for defining Custom Actions  such as SetDirectory, SetProperty, calling functions from VBScript and etc. I am thinking that the SetProperty custom action might be meant to set a new value to a Global Property session wide but I did not try it. You may explore the Custom Actions to see if you can get what you desired functionality done.

0 Kudos