Umer Waheed
Umer Waheed

Reputation: 4574

How to restrict user to change feature in case modify and upgrade in installer?

I have a installer which asks the user to select feature. Whatever user selects, it will never be changed in case of modify and upgrade the installation. For example: There are three features in my installer which are below:

      <Feature Id="Standalone" Title="Standalone" Level="2">
      </Feature>
      <Feature Id="CentralCase" Title="Central case" Level="2" >
      </Feature>
      <Feature Id="MiddleEF" Title="Middle Ef" Level="2" Display="expand">          
           <Feature Id="GUI" Title="Client" Level="3"></Feature>
           <Feature Id="AppServer" Title="Application Server" Level="3">  
      </Feature>
      </Feature> 

Now suppose user starts the installation and select the first feature which is standalone and install it. Now if user wants to modify, he should not allowed to change feature or even if user wants to upgrade, user should also not allowed to change feature. He can only upgrade what he selected at first time. Is there any way to do this?

Upvotes: 1

Views: 248

Answers (1)

Stein &#197;smul
Stein &#197;smul

Reputation: 42126

ARPNOMODIFY: I guess it depends how critical it is that these features never change. You can set the ARPNOMODIFY in the MSI to 1 and there will be no button to invoke Modify from:

 <Property Id="ARPNOMODIFY" Value="1" Secure="yes" />

Disclaimer below. Here be dragons.

msiexec.exe: However, you can still invoke modify by launching the MSI file itself (the default dialog sets should correctly disable the modify button though), but worse: you can go via the msiexec.exe command line and change anything you want:

msiexec /i "MySetup.msi" ADDLOCAL=MyFeature

This might be OK since it would appear to be seldomly used. However, you should be aware that remote management systems often rely on the msiexec.exe command line to handle MSI deployment, and as such the deployment system could be used to change feature state easily (via the deployment tool GUI, no command lines to deal with).

Custom Action: I don't know of an auto-magic way to abort setup if the user tries to modify the feature structure invoked via the msiexec.exe command line, but I suppose you can use a custom action maybe right before InstallInitialize in the InstallExecuteSequence to abort the installation if ADDLOCAL, REMOVE or ADVERTISE are set? If you do not condition this custom action properly, it could cause a package that won't uninstall at all or upgrade properly.

Some unverified conditioning suggestions: How to execute conditional custom action on install and modify only?

MigrateFeatureStates: For a major upgrade the GUI will not run as if it is running modify, but a fresh installation (since the product GUID is new). Hence the original installation GUI is shown and not the modify one. Accordingly you might need to disable some GUI controls or hide whole dialogs to prevent feature selection (not sure in WiX default dialogs). Added a link for that below. The standard action MigrateFeatureStates will take care of preserving the feature installation states between versions, provided you haven't done anything drastic to the feature structure. You enable this standard action to run in the Upgrade table. Should be default to run in WiX MSIs I think.

UPDATE:

Preselected Property: There is a special property called Preselected that is to automatically hide feature selection. You can try to set it or check whether it is set automatically by WiX to see if it hides feature selection. I have honestly never tried it.


Some Further Resources:

Upvotes: 1

Related Questions