detect msi parameters for unattended install

2019-03-13 02:50发布

问题:

I have a msi package that have option to install two different languages , is there a way to detect the parameter responsible for selecting the language so I can use the command prompt to install the package silently (unattended installation) ?

Thanks

回答1:

The normal way to do things with an MSI is any property in the property table who is named entirely with capital letters is considered a public external property. This means it is settable when you run the MSI from the command line.

So if you work out how you want to flag your language choice, put a property in for it, and then you can link the installation of components or features inside the MSI to that flag/variable.

So if you are not familiar with the concepts yet, check out components, features and properties of MSIs. You don't mention which MSI builder you are using - if you are using the one that comes with Visual Studio i don't know if it is capable of giving you access to the components and feature, but there are one or two low priced or free (i.e. Wix) alternatives out there that do (if you are using something proper like Wise or InstallShield then you have full control over all these things).

Edit: here is a link to a script that will extract a list of public properties for you (click on the text Get MSI-File properties.vbs to see the script). Alternatively, How can I see what public properties are available? and Extracting properties from MSI file without installing may provide you some other options.

The guys over on ServerFault will probably be able to help a lot more with this, I know there are some Windows admin tools that allow you to disassemble and/or wrap up MSis but I can't remember what they are called.



回答2:

(Note: I posted a variation of this response on a different StackExchange site for a similar question.)

lessmsi is a great tool that certainly works here if you're willing to pop open its GUI and do some manual investigation.

If you're looking for a quick fix, you can try:

lessmsi l -tProperty <msi_name>

Unfortunately, it is likely that the above command will not output the properties you're looking for (sidenote: the output is csv formatted).

One way to essentially guarantee that you get all the possible properties is to actually perform either an installation, repair, or uninstall with the MSI file and log the process. The following command records only the properties and nothing else:

<msi_name> /lp! <msi_property_logfile>

The above command is equivalent to:

msiexec /lp! <msi_property_logfile> /i <msi_name>

My preferred method, however, is to not actually install/remove/repair (and to simply extract instead). The advantages this method has over lessmsi is that it doesn't require a 3rd-party utility (i.e. lessmsi), and it doesn't require you to mess with any installations. Given that you have enough disk space to actually install the program, you can do:

msiexec /a <msi_name> /lp! <msi_property_logfile> TARGETDIR=<absolute_path_to_extract_to>

Note that the <absolute_path_to_extract_to> can point to a nonexistent directory (the command will create the directories necessary or fail).

If you hate the installation UI for whatever reason you can append the /qr option, which will 'reduce' and possibly eliminate the UI without impairing the property logging process. Be warned however--if you go "lower" than the reduced UI (viz. /qb|/passive or /qn|/quiet), your <msi_property_logfile> may be missing some properties.

Once the process has finished, you simply open up the logfile and note the lines beginning with Property(S):/Property(C):. Generally speaking, the parameters/properties that can be set for an install are logged in ALL CAPS; for example, ALLUSERS can be set ALLUSERS=1 so that the installation is for all users.

So for the example just given, your unattended mode installation could look something like:

msiexec /i <msi_name> /passive ALLUSERS=1