在 inno-setup 中创建连续的 cmd 提示符以启用 postgres 安装

Creating a continous cmd prompt in inno-setup to enable postgres installation

我正在使用 inno setup 并尝试安装 postgres,但是我无法在 运行 部分成功启动服务器,因为它关闭了我以管理员用户身份登录的 cmd 提示框.

有谁知道如何创建连续的 cmd 提示符以使我能够执行 postgres?

这是我的代码:

[Run]

Filename: "{cmd}"; Flags: runasoriginaluser; Parameters: "/k{src}\..\pgsql\bin/pg_ctl register -N postgres -U postgres -P postgres -D C:\eltfiles\pgsql\data -W -t -o {src}\..\pgsql\bin/initdb -U postgres -A password -E utf8 --pwfile={src}\..\pgsql\bin\password.txt -D C:\xxxfiles\pgsql\data"

Filename: "{cmd}"; Flags: runasoriginaluser; Parameters: "/k {src}\..\pgsql\bin/pg_ctl -D C:\xxxfiles\pgsql\data -l logfile start"

只需 运行 在您的 运行 部分中这样安装(无声):

[Run]
Filename: "{tmp}\postgresql.exe"; Parameters: "--mode unattended --unattendedmodeui none --datadir {commonappdata}\PostgreSQL.4\data --install_runtimes 0"; AfterInstall: CreateDatabase; 

从您的 AfterInstall 调用此方法:

function CreateDatabase() : Boolean;
var
  InstallPath: String;
  DataPath: String;
  ResultCode: Integer;

begin
  Result := False;

  InstallPath := ExpandConstant('{pf}\PostgreSQL.4\bin');
  DataPath := ExpandConstant('{#ProgramDataDirectory}\PostgreSQL.4\data');  

  //Clear old data out
  DelTree(DataPath, True, True, True);

  // First we must initialise our server
  if Exec(InstallPath + '\initdb', '-D ' + DataPath, '', SW_SHOW, ewWaitUntilTerminated, ResultCode) then
  begin
    // Now start our postgres process
    if Exec(InstallPath + '\pg_ctl', 'start -w -D ' + DataPath, '', SW_SHOW, ewWaitUntilTerminated, ResultCode) then
    begin
      // Create our database user
      if Exec(InstallPath + '\createuser', '-w -d -R -S username', '', SW_SHOW, ewWaitUntilTerminated, ResultCode) then
      begin
        // Create our database 
        if Exec(InstallPath + '\createdb', 'database', '', SW_SHOW, ewWaitUntilTerminated, ResultCode) then     
           Result := True;
        end;
      end;
    end;
  end
end;

这个有效我以前用过类似的东西。