When attempting to create a silent installer for a program, can I just use that program's setup.exe
in the tools folder and just generate a shim for it? If so, where does it then get installed to?
For example, I deleted all items in the tools folder and put in the setup.exe
for ARM RVDS 4.1
. When I did choco pack
it generated a shim but now I don't know what to do with it, or if I did it right.
You don't want to set up a shim for the installer - you want to invoke the installer from chocolateyInstall.ps1
to install the program. A sample of how you would do this in chocolateyInstall.ps1
for a setup exe would be:
$packageInstallArgs = @{
PackageName = 'package-name'
FileType = 'exe'
SilentArgs = '/q /someOtherArguments' # This line is going to be installer specific, and is just a sample here
File = 'C:\Path\to\installer' # can be a relative path too
ValidExitCodes = 0, 1638 # array of acceptable return codes for the installer
}
Install-ChocolateyInstallPackage @packageInstallArgs
If your
setup.exe
is embedded inside the package, you can reference the current package folder directory with the following environment variable:$env:chocolateyPackageFolder
. This variable only exists in the context of a Chocolatey package install. See here for more information on Chocolatey environment variables.
Some details about the code above:
0
) and reboot required (1638
). See this page for more information about standard installer exit codes. Search for the error codes that start with ERROR_SUCCESS
for the success codes you may need to support.You would optionally generate shims for programs not automatically placed on the PATH for convenience, in the case a shim is not automatically generated.
Where a program gets installed depends on the default location of the installer, and whether the installer allows you to override it.
Note that while automatically generated shims will be removed on uninstall automatically, shims created with Install-BinFile
need to be manually removed on package uninstall using Uninstall-BinFile
from chocolateyUninstall.ps1
.
Here is some more information about shims: