45352

How can I silently install an MSI package using msiexec installer with a list of options

Question:

I am trying to install an MSI package with around 10 options. I was hoping to create these options in a .txt file and pass those through to msiexec.exe during the install via the command line using a script such as this:

C:\Windows\System32\msiexec.exe /qn /i "C:\folder\Installer.msi" /L*V "C:\folder\Installerlog.txt" /t "C:\folder\Installer.switch.txt"

My installer.switch.txt file has a structure similar to this:

Option1=option1 ^ Option1=option2 ^ Option1=option3 ^

With this I hope to pass the options via the installer.switch.txt file. Could you please advise on firstly if this is possible and secondly which errors I might be making in the syntax.

Thanks

Answer1:

I have never seen the switch /t used with msiexec.exe - is this your own invention to indicate "text file with switches"? There are built-in ways to set installation parameters and settings that don't rely on text files.

Essentially you can set <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/aa370912(v=vs.85).aspx" rel="nofollow">public properties</a> used inside the MSI via the <strong>command line</strong> OR you can use a <strong>transform</strong> (which I find better). A transform is a partial database file - an MSI fragment - which is applied to change the original MSI at install time to customize anything you like in the MSI file.

In other words, I would use a transform to set these options and then apply it via msiexec.exe as described here in the top sections: <strong><a href="https://stackoverflow.com/questions/458857/how-to-make-better-use-of-msi-files/1055861#1055861" rel="nofollow">How to make better use of MSI files</a></strong>. The linked answer is quite long, just look for the sections on public properties and transform with the numbers 1 and 2 in front of each option.

<hr />

On a <strong>technical note</strong>: I would add any properties you want to use for your customizations to the <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/aa371571(v=vs.85).aspx" rel="nofollow">SecureCustomProperties</a> list to ensure they can be passed to the deferred mode server installation process.

This is quite technical, but may be important in fringe cases. It involves technicalities with regards to users installing with elevated rights (not admin rights). Just add all customized properties to the SecureCustomProperties list set in the MSI's property table. Your SecureCustomProperties list would read something like: PROP1;PROP2;PROP3 etc... You set this in your transform.

Answer2:

Its possible.

I have achieved this through .ini file. On silent installation we can get the ini file path and read the values using key.

Ini file is simple text files with a basic structure.

We can have n number of options in .ini file.

msiexec.exe /i "C:\folder\Installer.msi" /L*V "C:\folder\Installerlog.txt" /qb ConfigDirectory=C:\folder\Installer.switch.ini

Run the above command on cmd to install.

Below code is used to read and set the .ini file values.

public string IniReadValue(string Key, string Section = null) { StringBuilder temp = new StringBuilder(255); int i = GetPrivateProfileString(Section, Key, "", temp, 255, this.path); return temp.ToString(); } var MyIni = new IniFileRead("ConfigDirectory"); var importDir = MyIni.IniReadValue("Option1", "OptionDirectory"); var exporttDir = MyIni.IniReadValue("Option2", "OptionDirectory");

<strong>Installer.switch.ini</strong>

[OptionDirectory] Option1=value1 Option2=value2

Hope it helps.

Recommend

  • Read stdin in chunks in Bash pipe
  • Implicit property animations do not work with CAReplicatorLayer?
  • Change the width of the JQM panels
  • Validity Method for Reference Classes
  • What's a fast (non-loop) way to apply a dict to a ndarray (meaning use elements as keys and rep
  • Quick Question About Get and Set
  • Find VMID for running instance
  • Oracle - Second level subquery cannot see field from main query
  • cordova is not defined - cordova.js has already been loaded :: Ionic
  • Clarification on min distance on LocationManager.requestLocationUpdates method, min Distance paramet
  • Not able to aggregate on nested fields in elasticsearch
  • gspread or such: help me get cell coordinates (not value)
  • Visual Studio 2010 debugger build correctly - compiler pdb and linker pdb not in synch?
  • How do I exclude a dependency in provided scope when running in Maven test scope?
  • How to get Eclipse Oxygen to run on Java 9
  • MailKit: The IMAP server replied to the 'EXAMINE' command with a 'BAD' response
  • Q promise. Difference between .when and .then
  • NetLogo BehaviorSpace - Measure runs using reporters
  • Spring security and special characters
  • Array.prototype.includes - not transformed with babel
  • AES padding and writing the ciphertext to a disk file
  • Java applet as stand-alone Windows application?
  • How to convert from System.Drawing.Color to Excel.ColorFormat in C#? Change comment color
  • Why doesn't :active or :focus work on text links in webkit? (safari & chrome)
  • Validaiting emails with Net.Mail MailAddress
  • MySQL WHERE-condition in procedure ignored
  • JSON with duplicate key names losing information when parsed
  • Web-crawler for facebook in python
  • XCode can't find symbols for a specific iOS library/framework project
  • jqPlot EnhancedLegendRenderer plugin does not toggle series for Pie charts
  • How do I rollback to a specific git commit
  • Is there a mandatory requirement to switch app.yaml?
  • trying to dynamically update Highchart column chart but series undefined
  • C# - Getting references of reference
  • JTable with a ScrollPane misbehaving
  • unknown Exception android
  • Busy indicator not showing up in wpf window [duplicate]
  • failed to connect to specific WiFi in android programmatically
  • java string with new operator and a literal
  • How can I use threading to 'tick' a timer to be accessed by other threads?