1

Hello Experts I have made batch file to run query in postgresql it works fine after pressing enter key 4 times without typing. 1-server, 2 database, 3 port and 4 for password. I need this same result with single click. `

@echo off
REM Copyright (c) 2012-2016, EnterpriseDB Corporation.  All rights reserved

REM PostgreSQL server psql runner script for Windows

cmd.exe /c chcp 1252

SET server=localhost
SET /P server="Server [%server%]: "

SET database=naari
SET /P database="Database [%database%]: "
SET Password=pes

SET port=5432
SET /P port="Port [%port%]: "

SET username=postgres
SET /P username="Username [%username%]: "

for /f "delims=" %%a in ('chcp ^|find /c "932"') do @ SET CLIENTENCODING_JP=%%a
if "%CLIENTENCODING_JP%"=="1" SET PGCLIENTENCODING=SJIS
if "%CLIENTENCODING_JP%"=="1" SET /P PGCLIENTENCODING="Client Encoding [%PGCLIENTENCODING%]: "
REM Run psql
"C:\Program Files\PostgreSQL\10\bin\psql.exe" -h %server% -U %username% -d %database% -p %port% -f e:\DELETE.sql
pause

`

2
  • My previous question was for how to write batch file but now I am asking how to execute batch file in single click which i have written with the help of previous question. Right now my script is working fine by pressing enter key in four times. I want this same result in single click so do i use this batch file in schedule task in windows server. Commented Dec 4, 2017 at 10:13
  • See also here: stackoverflow.com/q/6405127/330315 for possible other solutions Commented Dec 4, 2017 at 10:55

1 Answer 1

1

Now I have a solutions.

@echo off
REM Copyright (c) 2012-2016, EnterpriseDB Corporation.  All rights reserved

REM PostgreSQL server psql runner script for Windows

cmd.exe /c chcp 1252

REM Run psql
"C:\Program Files\PostgreSQL\10\bin\psql.exe" -h localhost -U postgres -d naari -p 5432 -f e:\script.sql

pause
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.