Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting PGPASSWORD environment variable for Postgres (psql) process executed by Inno Setup

I needs to create a tablespace in Postgres with Inno Setup.

I had run this on the command line:

SET PGPASSWORD=P0stgres
"C:\Program Files\PostgreSQL\9.4\bin\psql.exe" -h localhost -p 5432 -U postgres -d postgres -c "CREATE TABLESPACE TABLETEST OWNER postgres LOCATION E'{app}\\PATHTEST\\Db'"

I tried this in Inno Setup, but it did not work:

[Run]
Filename: {sys}\cmd.exe; Parameters: "SET PGPASSWORD=P0stgres"
Filename: {sys}\cmd.exe; Parameters: ""C:\Program Files\PostgreSQL\9.4\bin\psql.exe" -h localhost -p 5432 -U postgres -d postgres -c "CREATE TABLESPACE TABLETEST OWNER postgres LOCATION E'{app}\\PATHTEST\\Db'""

Regards

like image 217
Robertopcn Avatar asked Mar 04 '16 21:03

Robertopcn


2 Answers

I am able to do it. There should be no space between password and &. PGPASSWORD=password&

Filename: "cmd.exe"; Parameters: "/c set PGPASSWORD=my_db_user& ""psql"" -U my_db_user -d myappdb -a -q -f C:\my\Manager\SQL\Sequences.sql & pause"; Flags: runascurrentuser;
like image 76
Linux Linux Avatar answered Oct 19 '22 04:10

Linux Linux


I was able to do it work. Was a little mistake. The correct is:

[Run]
Filename: {cmd}; Parameters: "/K SET PGPASSWORD=P0stgres&""C:\Program Files\PostgreSQL\9.4\bin\psql.exe"" -h localhost -p 5432 -U postgres -d postgres -c ""CREATE TABLESPACE TABLETEST OWNER postgres LOCATION '{app}\PATHTEST\Db'""
like image 40
Robertopcn Avatar answered Oct 19 '22 06:10

Robertopcn