Get command line arguments in Wix

2.2k views Asked by At

Is there is a way to get/enum properties passed using msiexec? I need to show an error if property is misspelled.

2

There are 2 answers

1
Stein Åsmul On

All properties set at the command line must be PUBLIC (uppercase) properties, and if they are set on the command line they should be added to the list of properties passed through to the server installation process via the SecureCustomProperties property delimited list of properties. Any property not listed here won't be available in deferred installation mode where changes of all kinds can be made since it runs with the LocalSystem account - the built-in operating system service account. The user interface sequence runs with user rights, and can be skipped entirely if the install is run silently.

If you keep this list of properties in SecureCustomProperties properties updated with all properties accepted set via the command line, you can enumerate over them with a simple string operation. You split the string by semicolon, and then enumerate all the values. You can set default values in the property table, and override them on the command line. Your code can check whether the values sent to the server process are the default ones or if they have been changed. You can even set an unacceptable value as default, so the property has to be overridden via command line.

Be aware of the EnableUserControl property.

5
Christopher Painter On

For some reason Windows Installer never implemented a property enumeration function. You can query the property table but that only gets you properties defined in the table at build time. I know of no way to do what you are trying to do. My best work around is to front end the MSI with an EXE bootstrapper and do your checks there. You can then pass something like EXEDRIVEN=1 to your MSI and then have your MSI gate check on that property.

Another thought is to use CLIENTPROCESSID to query Win32_Process in a custom action.