Chocolatey package creation: How to select a language for a silent installation

322 views Asked by At

While creating a package for chocolatey, the installation fails because the installer asks for a language selection: Window asking for the user's language for installation.

So I tried, as explained in this page to get the user's language (get-culture) and add it in the installation arguments by calling the variable ($locale):

$ErrorActionPreference = 'Stop';
$toolsDir   = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)"
$locale = "/L=" + (Get-Culture).LCID


$packageArgs = @{
  packageName   = 'PNAME'
  unzipLocation = $toolsDir
  file           = "PNAME32bit.exe"
  file64         = "PNAME64bit.exe"
  fileType      = 'EXE'
  silentArgs     = '/S $locale'
  softwareName  = 'PNAME*'
  validExitCodes= @(0)
}

Install-ChocolateyInstallPackage @packageArgs
Remove-Item $toolsDir\*.exe -ea 0 -force

Unfortunately, no change, this window still appears.

My question is therefore: how to specify during installation, the user's language so that this is taken into account by the installer?

Thank you in advance for your help !

1

There are 1 answers

1
pauby On

If the installer does not allow you to specify the language at the time of installation then you have two options:

  1. Use a tool such as AutoHotkey to perform the clicking of the language automatically (see the Veracrypt package for a good example of this);
  2. Wrap the installer into an MSI that you could then have the language automatically selected (you would likely have to create an MSI for every language);

The first one is relatively trivial to do but can be a little messy (Autohotkey would run in the background, detect the window, click the right language etc.). It may also get messy when you have to start 'clicking' the correct language. The second one would be the preferred method as it's less messy but would require some time working with the installer.

The ideal solution is of course to either find the correct parameter to pass to the installer OR get the vendor to add such a parameter.