我会用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" …
Run Code Online (Sandbox Code Playgroud)