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
- :
- Checking for Feature installation in InstallScript/BasicMSI
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
‎Feb 10, 2008
10:50 AM
Checking for Feature installation in InstallScript/BasicMSI
I have been finding it frustratingly difficult to ascertain in an InstallScript script whether a certain feature is being installed or not.
I have a script that runs on installation and uninstallation. It's supposed to see which features were selected and install a Windows service for that feature.
At first I tried using FeatureIsFeatureSelected(), but that apparently works only in InstallScript projects, and always returns TRUE in Basic MSI projects.
Now I'm trying to use MsiEvaluateCondition, like this:
However, this is also returning TRUE in all conditions, both during installation and uninstallation.
What am I doing wrong here?
I have a script that runs on installation and uninstallation. It's supposed to see which features were selected and install a Windows service for that feature.
At first I tried using FeatureIsFeatureSelected(), but that apparently works only in InstallScript projects, and always returns TRUE in Basic MSI projects.
Now I'm trying to use MsiEvaluateCondition, like this:
if (MsiEvaluateCondition(hMSI, "&ParentFeature\\SubFeatureA=3")) then
MessageBox("Installing FeatureA", INFORMATION);
elseif (MsiEvaluateCondition(hMSI, "&ParentFeature\\SubFeatureA=2")) then
MessageBox("Removing FeatureA", INFORMATION);
endif;
However, this is also returning TRUE in all conditions, both during installation and uninstallation.
What am I doing wrong here?
(8) Replies
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Feb 10, 2008
11:02 AM
Perhaps try this:
MsiEvaluateCondition(hMSI, "&SubFeatureA=3")
Unlike InstallScript, where (I think) features and subfeatures can have the same name, MSI internal feature names must be unique, and so you don't need the fully qualified name in the condition.
MsiEvaluateCondition(hMSI, "&SubFeatureA=3")
Unlike InstallScript, where (I think) features and subfeatures can have the same name, MSI internal feature names must be unique, and so you don't need the fully qualified name in the condition.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Feb 10, 2008
11:25 AM
I'm afraid that didn't do the trick. Still getting True.
Tried running it as Immediate, Deferred and Commit - same response for all. When is it supposed to run?
Tried running it as Immediate, Deferred and Commit - same response for all. When is it supposed to run?
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Feb 10, 2008
01:11 PM
Please see the MSI help topic "Conditional Statement Syntax"; in general, feature and component action and state conditions need to be used after CostFinalize.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Feb 11, 2008
09:40 AM
Also note that MsiEvaluateCondition has four possible return values, which per standard integer interpration means three of the four evaluate in an if as TRUE. I think MSICONDITION_FALSE was the sole FALSE one, so MSICONDITION_ERROR might be incorrectly considered TRUE in your code.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Feb 12, 2008
01:55 AM
That might be it. I'll check it now (damn the different syntax for IS functions and MSI functions!).
Is there a quicker way of doing this iterative code-compile-check cycle without running a full build for my project. It's a 1-2 minute build process every time. Is there an interactive debugger I can attach to a running installation?
Is there a quicker way of doing this iterative code-compile-check cycle without running a full build for my project. It's a 1-2 minute build process every time. Is there an interactive debugger I can attach to a running installation?
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Feb 12, 2008
02:32 AM
Apparently the MsiEvaluateCondition is returning MSICONDITION_ERROR (3). I don't know how to check what the error is. The documentation doesn't list MsiEvaluteCondition as one of the functions that sets the process error record, so I can't use MsiGetLastErrorRecord to see the error text.
I'm running as part of the Execute sequence, after InstallServices, so I'm a lot after CostFinalize.
I'm running as part of the Execute sequence, after InstallServices, so I'm a lot after CostFinalize.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Feb 12, 2008
03:43 AM
I've changed my code. Now instead of a "ManageServices" function that checks Feature state and installs services accordingly, I created several top-level functions ("export prototype"), created an InstallScript Custom Action for each, and used the conditions in the CA.
The very same condition seems to work as part of the sequence, but not inside my InstallScript code. Not going to waste any more time understanding why, it's swallowed way too much time already.
The very same condition seems to work as part of the sequence, but not inside my InstallScript code. Not going to waste any more time understanding why, it's swallowed way too much time already.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Feb 12, 2008
10:38 AM
Were you trying to run this code from within a deferred custom action? That might explain why otherwise valid condition strings could not be evaluated - if so reading up on and using CustomActionData might be the answer. If you want to debug different condition strings, it shouldn't be hard to write up a loop which prompts you for a condition string, evaluates it, and shows the results; but as you've noticed, the exact execution scheduling may change how it works.