首页 > 解决方案 > 在特定目录上的 Windows 上无人值守安装 PostgreSQL 失败

问题描述

我需要在无人值守模式下使用 NSIS 在 Windows 10 上安装 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

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

标签: postgresqlcommand-linewindows-10postgresql-11

解决方案


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

error.install.directory.nondefault 错误消息发生在以下情况:

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

当它已经安装时,如果以前的安装没有在默认目录中完成,则会发生错误。

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

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


推荐阅读