@echo off
SETLOCAL ENABLEDELAYEDEXPANSION
set ORACLESTRING=OracleOraDB
set SQLSTRING=SQL Server (MSSQLSERVER)

echo.
echo #########################################################################
echo.
echo This script will attempt to determine if you are running MS SQL Server
echo or Oracle Database for your Micros Simphony Database
echo.
echo This script MUST BE RUN ON YOUR SIMPHONY DATABASE SERVER
echo.
echo If the script is able to determine the database server type, it will
echo display it for you to communicate back to Avero
echo.
echo If you see an ERROR message, then the script was unable to determine 
echo the database type.  Make sure you are running on the Simphnoy database
echo server.  If you are on the server and are still getting an error 
echo then you may need to consult with your IT team or Oracle rep to determine
echo the database type
echo.
echo #########################################################################
echo.
echo RESULTS:

REM First check for Oracle DB
FOR /F "tokens=* USEBACKQ" %%F IN (`net start ^| findstr /c:"%ORACLESTRING%"`) DO (
    
  REM SET var!count!=%%F
  REM SET /a count=!count!+1
  set resultORACLE=%%F
)

REM Now Check for SQL Server DB
FOR /F "tokens=* USEBACKQ" %%F IN (`net start ^| findstr /c:"%SQLSTRING%"`) DO (
    
  REM SET var!count!=%%F
  REM SET /a count=!count!+1
  set resultSQL=%%F
)

REM Now check our results

if ["%resultORACLE%"]==[""] (	
    if ["%resultSQL%"]==[""] (
        echo * ERROR: Unable to determine Simphony database type: No Oracle Database or MS SQL Server services found
    ) else (
        echo * Found MS SQL Server service, you are running MS SQL Server for your Simphony Database
        echo MS SQL Server Service:
        echo %resultSQL%
	goto :done
    )
) else (
    if ["%resultSQL%"]==[""] (
        echo * Found Oracle Database service, you are running Oracle Database for your Simphony Database
        echo Oracle Database Service:
        echo %resultORACLE%
	goto :done
    ) else (
        echo * ERROR: Unable to determine Simphony database type: Found both Oracle Database and MS SQL Server services
        echo Oracle Database Service:
        echo %resultORACLE%
        echo MS SQL Server Service:
        echo %resultSQL%
    )
)

:done
echo.
echo #########################################################################
echo.
