Postgresql.cmd
@echo off
title PostgreSQL
rem variable setting
if not defined PGSQL set PGSQL =% ~ dp0
if not defined PGLOCALDIR set PGLOCALDIR =% PGSQL% share
if not defined PGDATABASE set PGDATABASE = postgres
if not defined PGPORT set PGPORT = 5432
if not defined PGUSER set PGUSER = postgres
rem data directory, set as needed
if not defined PGDATA set PGDATA =% PGSQL% \ Data \ data
rem log, set on demand
if not defined PGLOG set PGLOG =% PGSQL% \ Data \ log.txt
rem runs for the first time to initialize a new database
if not exist "% PGDATA%" (
echo.
Echo is initializing the database for the first time, please wait ...
"% PGSQL% \ bin \ initdb" -U% PGUSER% -A trust -E utf8 --locale = C> nul
)
rem start postgres server
echo.
"% PGSQL% \ bin \ pg_ctl" -D "% PGDATA%" -l "% PGLOG%" -w start
cls
echo.
echo Type \ q to exit and shut down the server
echo.
"% PGSQL% \ bin \ psql.exe" --port =% PGPORT% --dbname = "% PGDATABASE%" --username = "% PGUSER%"
echo.
"% PGSQL% \ bin \ pg_ctl" -D "% PGDATA%" stop
Decompression version of PostgreSQL startup script