在特定目录的 Windows 上无人值守安装 PostgreSQL 失败

Installing PostgreSQL unatended fails on Windows on a specific directory

我需要在无人值守模式下使用 NSIS 在 Windows10 上安装 Postgresql 11.3,为此我使用了 EnterpriseDB 安装程序 (https://www.enterprisedb.com/downloads/postgres-postgresql-downloads),但它失败并显示错误消息 "error.install.directory.nondefault".这个 nsis 脚本在 PosgreSQL 9.3 Windows 安装程序中运行良好。

下面这个简单的安装脚本不能在我的开发 PC 上运行,但可以在其他一些 PC 上运行:

;--------------------------------
; The name of the installer
Name "PostgreSQL 11 Installer"

; The file to write
OutFile "PostgreSQL11Installer.exe"

; Request application privileges
RequestExecutionLevel admin

;--------------------------------

;PostgreSQL Installation
Section "" 
  ExecWait 'C:\tmp\postgresql-11.3-1-windows-x64.exe  --unattendedmodeui minimal --mode unattended  --prefix C:\PostgreSQL11 --datadir C:\PostgreSQL11\data --serverport 5432 --superpassword mypassword'
SectionEnd

在 %TEMP% 文件夹中,bitrock_installer_xxxx.log 没有显示任何其他错误消息:

Log started 05/27/2019 at 12:24:43
Preferred installation mode : unattended
Trying to init installer in mode unattended
Mode unattended successfully initialized
Executing cscript //NoLogo "C:\Users\nducoin\AppData\Local\Temp\postgresql_installer_4263a06887\prerun_checks.vbs"
Script exit code: 0

Script output:
 The scripting host appears to be functional.

Script stderr:


[12:24:45] Using branding: PostgreSQL 11
Executing C:\Users\nducoin\AppData\Local\Temp/postgresql_installer_4263a06887/temp_check_comspec.bat 
Script exit code: 0

Script output:
 "test ok"

Script stderr:


error.install.directory.nondefault

有什么办法可以有更多的日志来调试这个问题吗?有谁知道会出什么问题吗?

来自https://postgresrocks.enterprisedb.com/t5/PostgreSQL/Postgresql-11-command-line-installation-fails-on-Windows-for-non/m-p/3698#M299

error.install.directory.nondefault 错误消息发生在:

  • 安装PostgreSQL的文件夹不为空
  • 语言环境不是英语
  • 安装文件夹不是默认安装文件夹
  • 尚未安装 PostgreSQL。

如果之前的安装未在默认目录中完成,则已安装时会出现错误。

本地化问题是 PostgreSQL 安装程序中的一个错误,其余是需要的行为。

获得正确错误消息的解决方案是将语言环境强制为英语: postgresql-11.3-1-windows-x64.exe --unattendedmodeui minimal --mode unattended --prefix “C:\PostgreSQL11” --datadir “C:\PostgreSQL11\data” --serverport 5432 --superpassword 测试--installer-language -en