This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- InstallShield
- :
- InstallShield Forum
- :
- MsiGetProperty inconsistencies
Subscribe
- 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
‎Jun 11, 2009
01:58 PM
MsiGetProperty inconsistencies
I am using an InstallScript MSI and am having problems getting property values from MsiGetProperty inside my InstallScript. Is there some reason that would explain it because it makes no sense to me.
nvBufferSize = MAX_PATH;
MsiGetProperty(ISMSI_HANDLE, "SUPPORTDIR", svSupportDir, nvBufferSize);
Those lines in a function called by a custom action work. However, those same lines inside of a function called from FirstUIAfter doesn't return any thing. However, the INSTALLDIR property has a value in FirstUIAfter.
I have seen this happen with other values too. And my biggest frustration is that there doesn't seem to be any rhyme or reason to it.
What am I missing?
nvBufferSize = MAX_PATH;
MsiGetProperty(ISMSI_HANDLE, "SUPPORTDIR", svSupportDir, nvBufferSize);
Those lines in a function called by a custom action work. However, those same lines inside of a function called from FirstUIAfter doesn't return any thing. However, the INSTALLDIR property has a value in FirstUIAfter.
I have seen this happen with other values too. And my biggest frustration is that there doesn't seem to be any rhyme or reason to it.
What am I missing?
(2) Replies
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jun 11, 2009
02:49 PM
MSI properties set during the pre-file transfer events (OnBegin, OnFirstUIBefore, etc.) or set during immediate custom actions will lose their values in post-file transfer events (OnFirstUIAfter, OnEnd, etc.). This is an unintended side-effect due to how InstallScript MSI projects are implemented.
The basic reason for this is the InstallScript engine acts as an external UI handler for the MSI package being installed. In order to interact with Windows Installer, the InstallScript engine opens an installation session through the MsiOpenPackage API. All properties set during pre-file transfer events are backed by this installer session. Just before file-transfer is started, this installer session needs to be closed, otherwise, Windows Installer would be unable to read the MSI package and the install would fail. A consequence of closing the session is any properties set during that session are essentially lost. Properties that are Directory table entries, such as INSTALLDIR, are reinitialized after file-transfer by running the Windows Installer costing actions.
If you need to maintain property values between pre and post file transfer events in InstallScript, global variables should be used in addition to or instead of MSI properties. Properties set during custom actions in the execute sequence would need to be written to a file or registry entries on the machine as there is no way to pass global variables from InstallScript custom actions to InstallScript events.
The basic reason for this is the InstallScript engine acts as an external UI handler for the MSI package being installed. In order to interact with Windows Installer, the InstallScript engine opens an installation session through the MsiOpenPackage API. All properties set during pre-file transfer events are backed by this installer session. Just before file-transfer is started, this installer session needs to be closed, otherwise, Windows Installer would be unable to read the MSI package and the install would fail. A consequence of closing the session is any properties set during that session are essentially lost. Properties that are Directory table entries, such as INSTALLDIR, are reinitialized after file-transfer by running the Windows Installer costing actions.
If you need to maintain property values between pre and post file transfer events in InstallScript, global variables should be used in addition to or instead of MSI properties. Properties set during custom actions in the execute sequence would need to be written to a file or registry entries on the machine as there is no way to pass global variables from InstallScript custom actions to InstallScript events.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jun 11, 2009
03:02 PM
Thank you! This is very informative.
