Register Start Pg_install.bat:
echo offset pgsql_dir=%~dp0if not "%pgsql_home%" = "" "(If not"%pgsql_home% "= ="%pgsql_dir% "(Echo pgsql_home=%p Gsql_home%! = pgsql_dir=%pgsql_dir% goto pg_ends)) Else (set pgsql_home=%pgsql_dir% echo Pgsql_home must be set as pgsql_dir=%pgsql_dir%) set path=%pgsql_home%bin;%pgsql_home%lib;%path%pg_isready-h localhost 1>nul 2> nul@if "%errorlevel%" = = "0" (Echo PostgreSQL is running. Goto pg_ends) echo "pgsql_home =%pgsql_home%" echo Install and start PostgreSQL server ... @if not exist%pgsql_home%data (m Kdir%pgsql_home%data%pgsql_home%bin/initdb--username=root--pgdata=%pgsql_home%data--encoding=UTF8--locale= Chineserem @if not "%errorlevel%" = = "0" (Rem there ERRORLEVEL is 2, but successfully initedrem Echo PostgreSQL Initdb FAI Led.rem goto Pg_endsrem)) pg_ctl Register--pgdata=%pgsql_home%data-n pgsql_srv-s demandnet start Pgsql_srvrem pg_ctl- W startpg_isready-h localhost 1>nul 2>nul@if "%errorlevel%" = = "0" (Echo PostgreSQL serveR started successfully) else (Echo Failed to start PostgreSQL server):p g_endscmd/k
Deactivate uninstall Pg_stop.bat:
@echo off
echo Stop and uninstall PostgreSQL server ...
pg_isready-h localhost 1>nul 2>nul@if "%errorlevel%" = = "0" (net stop pgsql_srv)
Pg_ctl unregister-n pgsql_srv@if "%errorlevel%" = = "0" Echo Unregister PostgreSQL successfully
: My_ends
PostgreSQL Registration starts and deactivates the Unload batch script