【发布时间】:2014-07-08 06:56:55
【问题描述】:
我会使用 NSIS 安装程序安装 postgresql,但我不知道如何。
你能帮帮我吗?
我找到了这段代码
outfile "C:\project-open\installer\install_postgres.exe"
Name "Install PostgreSQL"
!include Registry.nsh
!include LogicLib.nsh
!include MultiUser.nsh
!include Sections.nsh
!include MUI2.nsh`
!define TARGET c:\project-open
Function .onInit
StrCpy $INSTDIR "c:\project-open"
FunctionEnd
section
UserMgr::CreateAccountEx "postgres" "*******" "PostgreSQL" "PostgreSQL Database User" "Database user created by ]po[ installer" "UF_PASSWD_NOTREQD|UF_DONT_EXPIRE_PASSWD"
pop $R0
DetailPrint "After creating account: result=$R0"`
UserMgr::AddPrivilege "postgres" "SeBatchLogonRight"
pop $R0
DetailPrint "SeBatchLogonRight: result=$R0"
UserMgr::AddPrivilege "postgres" "SeServiceLogonRight"
pop $R0
DetailPrint "SeServiceLogonRight: result=$R0"
nsExec::ExecToLog '"$INSTDIR\pgsql\bin\initdb.exe" --username=postgres --locale=C --encoding=UTF8 -D "$INSTDIR\pgsql\data"'
pop $R0
DetailPrint "After initializing database: result=$R0"
nsExec::ExecToLog 'sc create postgresql-9.2 binpath= "c:\project-open\pgsql\bin\pg_ctl.exe runservice -N postgresql-9.2 -D c:/project-open/pgsql/data -w" DisplayName= "PostgreSQL 9.2" start= "demand" type= own obj= ".\postgres" password= "******" '
pop $R0
DetailPrint "After registering the service: result=$R0"sectionEnd`
但我对UserMgr::CreateAccountEx 有疑问,但我已导入所需的所有文件。
【问题讨论】:
-
我尝试使用 NSIS 安装 Postgres。因为我有一个使用 Postgres 的应用程序,并且在安装过程中使用我的应用程序安装 Postgre 很重要。否则我的应用程序不起作用
-
我只想写一个小 NSIS 脚本 (.nsi) 来安装 PostgreSQL。我用我对这个装置的不同研究来编辑我的主题。
-
Postgres 不再需要自己的帐户。并且最好使用
pg_ctl -register来创建服务。 -
好的,我会看到的。但是为什么我在创建帐户时遇到了问题?
-
不知道,但由于您不需要它,所以将其忽略(您也可能想将问题改写为“使用 NSIS 安装程序不工作的 CreateAccountEx”或类似的东西。这不是与 Postgres 直接相关。
标签: postgresql nsis