ichadhr
5/22/2015 - 4:25 PM

Batch script Postgresql service

Batch script Postgresql service

@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