@ECHO OFF

:: Check for administrator rights using net session
net session >nul 2>&1
if %errorLevel% neq 0 (
    echo Requesting administrative privileges...
    powershell -Command "Start-Process '%~f0' -Verb RunAs"
    exit /b
)

CD /D %~dp0
SET root=%~dp0
:QUERY
SC QUERYEX iTurboSvc
IF %ERRORLEVEL% == 0 GOTO :START

:CREATE
SC CREATE iTurboSvc binPath= "%root%iTurboSvc.exe" start= auto
IF NOT %ERRORLEVEL% == 0 GOTO :FAIL
SC DESCRIPTION iTurboSvc "System Fast Turbo and Fast Saving"
IF NOT %ERRORLEVEL% == 0 GOTO :FAIL

:START
:: REG CONFIG
reg import config.reg
:: CALL SVC
SC START iTurboSvc
set errcode=%ERRORLEVEL%
IF %errcode% == 0 GOTO :CALLCON
IF %errcode% == 1056 GOTO :CALLCON

:FAIL
ECHO SETUP ITURBO SVC FAIL
ECHO FAIL!FAIL!FAIL!FAIL!FAIL!
color 4f
PAUSE
EXIT /B1

:CALLCON

cls
ECHO SETUPED ITURBO SVC
ECHO PASS!PASS!PASS!PASS!PASS!
color 2f
timeout /t 3
EXIT /B0
