Created
November 7, 2022 20:50
-
-
Save albertopasqualetto/e88fee17459fbf05b7cbd1e4983c13be to your computer and use it in GitHub Desktop.
Start or stop postgresql service if it is (not) running
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
:: Source: https://stackoverflow.com/questions/1894967/how-to-request-administrator-access-inside-a-batch-file | |
:: Source: https://stackoverflow.com/questions/4051883/batch-script-how-to-check-for-admin-rights | |
:: batch code to request admin previleges, if no admin previleges | |
fltmc >nul 2>&1 | |
if NOT %errorLevel% == 0 ( | |
powershell start -verb runas '%0' am_admin & exit /b | |
) | |
net start | findstr /c:"postgresql-x64-15" >nul 2>&1 | |
if errorlevel == 1 ( | |
echo Starting postgresql... | |
net start postgresql-x64-15 | |
pause | |
) else ( | |
echo Stopping postgresql... | |
net stop postgresql-x64-15 | |
pause | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This has to be updated using
\PostgreSQL\15\scripts\runpsql.bat
, the file used by default after a postresql install.