@echo off set pgdir=./ set ctl=%pgdir%/bin/pg_ctl set dir=%pgdir%/data set pid=%dir%/postmaster.pid if exist "%pid%" ( echo postmaster.pid exists and PostgreSQL have been started possibly. goto ask ) else ( "%ctl%" -D "%dir%" start ) :ask set /p inp="press [R] to restart PostgreSQL, [Q] to quit : " if "%inp%"=="R" ( "%ctl%" -D "%dir%" restart goto ask ) else if "%inp%"=="Q" ( "%ctl%" -D "%dir%" stop goto :eof ) goto ask