echo off
if "%OS%" == "Windows_NT" setlocal

set "CURRENT_DIR=%cd%"
::cd ..
set "APPLICATION_SERVICE_HOME=%cd%"
cd "%CURRENT_DIR%"

set PR_LOGPATH=%APPLICATION_SERVICE_HOME%\logs
set SERVICE_NAME=atualizador_touchcomp
set BASE_DIR=%APPLICATION_SERVICE_HOME%\dist
set BASE_DIR_LIB=%BASE_DIR%\lib
 
set PR_INSTALL=%APPLICATION_SERVICE_HOME%\bin\prunsrv.exe
 
@REM Service Log Configuration
set PR_LOGPREFIX=%SERVICE_NAME%
set PR_STDOUTPUT=auto
set PR_STDERROR=auto
set PR_LOGLEVEL=Debug
 
@REM Path to Java Installation
set PR_CLASSPATH=%BASE_DIR%\AtualizadorTouch.jar;%BASE_DIR_LIB%\commons-codec-1.10.jar;%BASE_DIR_LIB%\contato_Util.jar;%BASE_DIR_LIB%\ContatoCore.jar;%BASE_DIR_LIB%\firebirdsql-full.jar;%BASE_DIR_LIB%\jackson-all-1.9.9.jar;%BASE_DIR_LIB%\jdom-2.0.2.jar;%BASE_DIR_LIB%\log4j-1.2.17.jar;%BASE_DIR_LIB%\quartz-all-2.1.3.jar;%BASE_DIR_LIB%\slf4j-api-1.6.1.jar;
@REM Startup Configuration
set START_CLASS=atualizadortouch.Main
 
set PR_STARTUP=auto
set PR_STARTMODE=jvm
set PR_STARTCLASS=%START_CLASS%
 
@REM Shutdown Configuration
set PR_STOPMODE=jvm
set PR_STOPCLASS=%START_CLASS%
%PR_INSTALL% //US/%SERVICE_NAME% ^
  --DisplayName="%SERVICE_NAME%" ^
  --Install="%PR_INSTALL%" ^
  --Classpath="%PR_CLASSPATH%" ^
  --StartMode="%PR_STARTMODE%" ^
  --StartClass="%START_CLASS%" ^
  --StopMode="%PR_STOPMODE%" ^
  --StopClass="%PR_STOPCLASS%" ^
 
if not errorlevel 1 goto installed
echo Failed to install "%SERVICE_NAME%" service.  Refer to log in %PR_LOGPATH%
goto end
 
:installed
echo The Service "%SERVICE_NAME%" has been installed
 
:end