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
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'""
I am able to do it. No space should be there 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;
You have three problems:
cmd.exe
needs /C
switch before the command. cmd.exe
instance that runs the psql.exe
. You have to execute both commands within the same cmd.exe
instance. One of the ways is using &
"operator" (another way is using a wrapper batch file to execute both commands).C:\\...\\psql.exe
and CREATE TABLESPACE ...
) have to be doubled .{cmd}
constant instead of {sys}\\cmd.exe
.[Run]
Filename: "{cmd}"; Parameters: "/C 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'"""
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.