How do I pass parameters to the installer in a Chocolatey package?

Raghav picture Raghav · Jun 14, 2016 · Viewed 15.7k times · Source

I created a package from an MSI. However, I need to pass in custom parameters.

/i SERVER='xx.yyy.com

Here are the few things I tried by reading the choco command spec, but none worked.

> choco install foo -y --params "SERVER='xx.yyy.com'"
> choco install foo -y --params "SERVER=xx.yyy.com"
> choco install foo -y --params "SERVER= xx.yyy.com"

How do I pass the install options to the installer?

Answer

ferventcoder picture ferventcoder · Jun 14, 2016

If you are passing to the native installer, please use --install-arguments and not --package-parameters.

https://chocolatey.org/docs/commands-install#options-and-switches

 --ia, --installargs, --installarguments, --install-arguments=VALUE
 InstallArguments - Install Arguments to pass to the native installer in 
   the package. Defaults to unspecified.

-o, --override, --overrideargs, --overridearguments, --override-arguments
 OverrideArguments - Should install arguments be used exclusively without 
   appending to current package passed arguments? Defaults to false.

 --params, --parameters, --pkgparameters, --packageparameters, --package-parameters=VALUE
 PackageParameters - Parameters to pass to the package. Defaults to 
   unspecified.

Additionally, you may want to explore the documentation on how to pass options and switches - https://chocolatey.org/docs/commands-reference#how-to-pass-options-switches:

  • Quote Values: When you need to quote an entire argument, such as when using spaces, please use a combination of double quotes and apostrophes ("'value'"). In cmd.exe you can just use double quotes ("value") but in powershell.exe you should use backticks ( `"value`") or apostrophes ('value'). Using the combination allows for both shells to work without issue, except for when the next section applies.
  • Pass quotes in arguments: When you need to pass quoted values to to something like a native installer, you are in for a world of fun. In cmd.exe you must pass it like this: -ia "/yo=""Spaces spaces""". In PowerShell.exe, you must pass it like this: -ia '/yo=""Spaces spaces""'. No other combination will work. In PowerShell.exe if you are on version v3+, you can try --% before -ia to just pass the args through as is, which means it should not require any special workarounds.