How to remove a feature from msi feature selection tree at runtime?

0

When we launch an msi, after some screens we will get the feature selection page.

Feature selection page:

enter image description here

We can remove any feature by just changing the feature table, display column value to 0.

But how to alter it at runtime, I mean, based on some property value,which might get altered from a different custom dialog we add or based on a custom action.

I tried by creating a property and adding that property at the display column of feature table as [Property1].

But it is not accepting non-integer values.

Any suggestion, how to implement this please.

I tried this so far.

Created a custom action of vbscript type

UpdateFeatureDisplay "erwinDM",Session.Property("DM_VISIBLE")   
UpdateFeatureDisplay "NoSQLStandalone",Session.Property("NS_VISIBLE")   

Sub UpdateFeatureDisplay(featureName,display)   
    Set viewlist = Database.OpenView("SELECT * FROM `Feature` WHERE `Feature`='"& featureName &"'")
    viewlist.Execute
    Set reclist = viewlist.Fetch
    viewlist.Modify 6 , reclist
    reclist.StringData(5)= CStr(display)
    'reclist.IntegerData(5)= CInt(display)
    viewlist.Modify 7 , reclist 
    viewlist.Close
End Sub

And, kept it to trigger when I click next , before the custom feature selection page.Where I take values from the check boxes.

But I am getting error in the log as below.

MSI (c) (14:B4) [17:50:30:269]: Note: 1: 1720 2: setFeatureDisplay 3: -2147467259 4: Msi API Error 5: Modify,Mode,Record 6: 8 7: 2 
Action ended 17:50:30: setFeatureDisplay. Return value 1.

Instead of keeping it in the Next event of dialog, if I keep it after setupinitilialization of ui sequence, it is not giving the above error.But not reflecting in the feature page also.

If we pass the property value, which are altering using UI, as a command line parameter, then only it is reflecting.I mean, during launch of msi.

user2331760

Posted 2019-04-29T10:52:42.770

Reputation: 1

Installation state of a feature is controlled by Level of feature and INSTALLLEVEL property. – montonero – 2019-04-29T13:17:29.697

Thanks for the reply, but I am asking for display of features at the custom install dialog selection tree, I mean in the UI. – user2331760 – 2019-04-29T18:47:17.720

Answers

0

If you want to remove the feature from a tree at a runtime then you'll need to modify Feature table with an SQL query within a custom action. Something like this (I didn't test the code but it should be pretty close to your needs):

featurename="Your Feature Name"
Set oView = Database.OpenView("SELECT * FROM `Feature` WHERE `Feature`='"&featurename&"'")
oView.Execute

' test on first Feature record
Set oRecord = oView.Fetch

' delete the original
oView.Modify 6, oRecord

' modify and temporarily write back new
oRecord.IntegerData(5) = 0
oView.Modify 7, oRecord

' close up shop
oView.Close

montonero

Posted 2019-04-29T10:52:42.770

Reputation: 540

I tried this script..But not reflecting..Any suggestions? – user2331760 – 2019-04-30T21:20:23.390

Please be more descriptive. Have you looked the installation logs? How did you created the custom action? – montonero – 2019-04-30T23:33:03.903

Added the details in the question by editing it again, can you please check it once. – user2331760 – 2019-05-02T12:27:58.087

Do not use UI sequence, use only InstallExecuteSequence. Otherwise you'll get in troubles with silent installation. And why you're using StringData instead of IntegerData? As far as I can see, Display column is integer type. According to the log, something is wrong with this line viewlist.Modify 6 , reclist. Check that reclist is not nothing. – montonero – 2019-05-03T20:47:17.077

Yeah, I got same error for both StringData and IntegerData.And, I want to execute this custom action only when user clicks on next button after a particular dialog.As I am checking the value of a checkbox on that dialog and only run this action if the checkbox is unchecked.So, I kept in UI sequence. – user2331760 – 2019-05-06T08:53:20.493

Have you checked that reclist is not nothing? – montonero – 2019-05-06T09:05:19.873