Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Determine if MSI/EXE supports certain flag/argument?

I'm creating an auto-updater that can run MSIs and EXEs. These MSIs/EXEs aren't my own. I'd like to use any unattended/silent install option if it exists. Is there some way to determine if an MSI/EXE has some sort of unattended install support and, if so, get the right argument so I can pass it to the file when I run it? I know, by default '/quiet' is the silent install option, but I'm also curious about EXEs and any MSIs that maybe have customized this option.

This question - detect msi parameters for unattended install - is similar, but the links in the answer are broken and I can't figure out from the answer what I would do.

Thanks.

like image 924
Chad Avatar asked Sep 04 '11 21:09

Chad


People also ask

How do I check MSI arguments?

When you install an MSI file, you can be assured that certain parameters will exist, such as the silent parameter /quiet or /qn. You can get a list of the supported parameters in PowerShell or CMD by typing msiexec.exe /?. This command will display the usage statement.

How do I find MSI installation options?

The Windows Installer MSI options can be found by opening a command window (click the Windows Start button, type in cmd and press ENTER on the keyboard), and in the command window typing msiexec /? and pressing ENTER on the keyboard.

How can I tell if an exe has a silent switch?

Open the program and browse for your setup.exe. This will display various information on the setup exe, such as what tools have been used to package the installer, what parameters are supported, etc. However, as mentioned previously in this article, not all the programs support the silent switch.

How do I find MSI properties?

To use properties in your installation, you can get and set property values from programs using MsiGetProperty and MsiSetProperty and include as part of conditional statements in the installation database. To obtain a current property, call the MsiGetProperty function.


3 Answers

Just run through the installer with logging turned on and it will show you all of the possible parameters that the specific MSI accepts.

For example: msiexec /log logfile.txt /i installer.msi

Run through the entire installer and the logfile.txt will show you the passable parameters as "Property(S)" or "Property(C)" with the name in all caps.

Source: http://www.codeproject.com/Articles/16767/How-to-Pass-Command-Line-Arguments-to-MSI-Installe

like image 171
Jon Heese Avatar answered Oct 27 '22 12:10

Jon Heese


(Note: I posted a variation of this response on the detect msi parameters for unattended install question you mentioned.)

There's lessmsi, is a great tool that certainly works here if you're willing to use a GUI and do some manual investigation.

You can try the following command:

lessmsi l -tProperty <msi_name>

...But it's unlikely that the above will have everything you're looking for.

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 as mentioned in Jon Heese's answer.

If you want less text to sift through in the log file, you can set the log setting to log only the properties:

<msi_name> /lp! <msi_property_logfile>

or

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

I prefer a method that bypasses the need of install/remove/repair-ing through "extraction". 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. You do need to have enough disk space to actually install the program (and probably some additional space, to be safe). Then you can do something like:

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.

The following command can effectively produce a Property log file for each MSI file in some directory (use DIR /B rather than DIR /B/S to not recurse subdirectories; remove the RD command if you want to keep the extracted files):

cmd /C "FOR /F delims^=^| %G IN ('DIR /B/S "%DirToSearch%\*.msi"') DO msiexec /a "%G" /qr /lp! "%~nG_log.txt" TARGETDIR="%~dpnG_extract" && RD /S/Q "%~dpnG_extract""

and if you want to run that in PowerShell for whatever reason, use the command below instead:

cmd /C "FOR /F delims^=^| %G IN ('DIR /B/S ""%DirToSearch%\*.msi""') DO msiexec /a ""%G"" /qr /lp! ""%~nG_log.txt"" TARGETDIR=""%~dpnG_extract"" && RD /S/Q ""%~dpnG_extract"""

Once the process has finished, you simply open up the logfile and note the lines beginning with Property(S):/Property(C):as Jon Heese mentioned.

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.

like image 34
YenForYang Avatar answered Oct 27 '22 13:10

YenForYang


If it's MSI, then the parameters are standard, you can get the list of options with msiexec /? or view the docs on MSDN.

There's no way to detect options for an arbitrary EXE which options it supports, if any. Try to find docs from the vendor, or try /? switch…

like image 33
Alexey Ivanov Avatar answered Oct 27 '22 13:10

Alexey Ivanov