Is it possible to fail an msi installation if an unrecognized parameter is supplied?
-
21-12-2019 - |
Question
For example, if the user mistypes an argument I want to fail the installation rather than proceed with some default value.
Assume I have an MSI package that optionally accepts some argument named SOMEPROPERTY.
msiexec /i myProduct.msi SOMEPROPERTY=abc
should work
msiexec /i myProduct.msi
should work
but
msiexec /i myProduct.msi SUMPROPERTY=abc
should fail for the presence of the unknown argument.
Is this possible? If so, how?
Solution
I would reset your customer and/or manager expectations. I would argue SUMPROPERTY is an irrelevant property and that it works as designed because SOMEPROPERTY is null. Alternatively require SOMEPROPERTY to have same value even it's 0 or another property such as IGNORESOMEPROPERTY=1.
Otherwise you run into a whitelist problem that's nearly impossible to solve as MSIEXEC.EXE passes properties into your session that are expected but not in your list of properties. There is also no API I'm aware of to get the list of properties to pass. Combine all this and your asking for trouble.
An alternative would be to create an EXE front end that does more extensive validation and calls your MSI with a special property (MSIEXEDRIVEN=1) that says it's safe to proceed.
OTHER TIPS
You can create a launch condition. The following condition fails if SOMEPROPERTY
is set and the value is not "123".
<Condition Message="Unknown property value">NOT SOMEPROPERTY OR SOMEPROPERTY="123"</Condition>