13

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.

Community
  • 1
  • 1
Chad
  • 3,159
  • 4
  • 33
  • 43
  • In what way are they broken? Errors? Things just aren't showing up? Specifying this in your question might allow people to help you un-break them. – Merlyn Morgan-Graham Sep 04 '11 at 21:42
  • This link - http://www.scriptbox.at.tt/index.php?search=Get%20MSI-File%20properties.vbs&site=1 - that was the one in the answer that has a script is broken. – Chad Sep 04 '11 at 22:35

3 Answers3

41

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

matt wilkie
  • 17,268
  • 24
  • 80
  • 115
Jon Heese
  • 411
  • 4
  • 3
  • 1
    Awesomely simple and straightforward compared to all the other scripts and now-dead-link programs in other answers. Thank you! – matt wilkie Jun 24 '15 at 21:03
5

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…

Alexey Ivanov
  • 11,541
  • 4
  • 39
  • 68
  • Okay, I figured there wouldn't be any way to easily figure out if an executable has certain features, but it was worth it to ask. I don't know who the vendors would be, so I can't just read their docs. Thanks. – Chad Sep 06 '11 at 00:19
  • 1
    @Chad You can try to look through strings in the exes, with a text editor. Usually you can see all switches there: the program needs these strings to compare arguments. If .exe is Unicode, you'll see “spaces” between each character. This is alike reverse engineering but it can help sometimes. – Alexey Ivanov Sep 06 '11 at 07:04
3

(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.

YenForYang
  • 2,998
  • 25
  • 22
  • Thank you for your decision! Great program! The task appeared to install `UACoreSvcSetup.msi` in silent mode and pass the value of the host name and port. These parameters are not included in the official documentation!!! Run `lessmsi`, select the file, `Table View` and `CustomAction` tables. `msiexec /i UACoreSvcSetup.msi UAVR_SERVERNAME="servername" UAVR_SERVERPORT="123"` – KUL Aug 13 '20 at 06:47