- Revenera Community
- :
- InstallShield
- :
- InstallShield Forum
- :
- Re: MsiGetProperty and MsiSetProperty help
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
MsiGetProperty and MsiSetProperty help
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.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
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.
![](/skins/images/8C9D13A71C7F7695F3262372C0172D68/responsive_peak/images/icon_anonymous_message.png)