Last active
October 7, 2019 15:48
-
-
Save ichadhr/35383275d5dd39febebd to your computer and use it in GitHub Desktop.
Batch script Postgresql service
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 | |
CLS | |
goto CHECK | |
:CHECK | |
net session >nul 2>&1 | |
if %errorLevel% == 0 ( | |
goto :MENU | |
) else ( | |
echo Checking permission privilege... | |
ping 1.1.1.1 -n 1 -w 500 > nul | |
echo You're not running this script as administrative privilege !! | |
ping 1.1.1.1 -n 1 -w 500 > nul | |
echo Run user account control "UAC" | |
ping 1.1.1.1 -n 1 -w 500 > nul | |
net session >NUL 2>&1|| powershell Start-Process '%0' -Verb RunAs&& exit /b|| exit /b | |
goto :MENU | |
) | |
:MENU | |
C: | |
CD\ | |
CLS | |
ECHO ============= POSTGRESQL SERVICE ============= | |
ECHO ------------------------------------- | |
ECHO 1. Run Postgresql Service | |
ECHO 2. Stop Postgresql Service | |
ECHO ------------------------------------- | |
ECHO 0. Exit | |
ECHO ------------------------------------- | |
ECHO. | |
SET INPUT= | |
SET /P INPUT=Please select a number: | |
IF /I '%INPUT%'=='1' GOTO :run | |
IF /I '%INPUT%'=='2' GOTO :stop | |
IF /I '%INPUT%'=='0' GOTO :quit | |
ECHO. | |
ECHO. | |
ECHO ============INVALID INPUT============ | |
ECHO Please select a number from the Main | |
echo Menu [1-2] or select '0' to quit. | |
ECHO ------------------------------------- | |
PAUSE | |
GOTO :MENU | |
:run | |
net start postgresql-x64-9.4 | |
ECHO. | |
ECHO. | |
goto :choice | |
:stop | |
net stop postgresql-x64-9.4 | |
ECHO. | |
ECHO. | |
goto :choice | |
:quit | |
EXIT | |
:choice | |
set /P c=Do you want close this program? (Y/N) | |
if /I "%c%" EQU "Y" goto :quit | |
if /I "%c%" EQU "N" goto :MENU |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment