0
votes

I am using inno setup and trying to install postgres, however I cannot successfully boot up the server in the run section because it closes out of my cmd prompt box where I am logged in as the admin user.

Does anyone know how to create a continuous cmd prompt to enable me to do postgres?

Here is my code:

[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"
1
Can you elaborate? I have no idea what you ask for. Maybe some screenshots would help.Martin Prikryl
After initializing the db with the first prompt, i use the second prompt and to start the database, but cannot because i get an access denied error.Dant.A

1 Answers

0
votes

Just run the installation in your run section like this (silent):

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

Call this method from your AfterInstall:

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

begin
  Result := False;

  InstallPath := ExpandConstant('{pf}\PostgreSQL\8.4\bin');
  DataPath := ExpandConstant('{#ProgramDataDirectory}\PostgreSQL\8.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;

This works I've used something similar before.