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

`

Stream
  • 89
  • 1
  • 9
  • 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. – Stream Dec 04 '17 at 10:13
  • See also here: https://stackoverflow.com/q/6405127/330315 for possible other solutions –  Dec 04 '17 at 10:55

1 Answers1

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
Stream
  • 89
  • 1
  • 9