@echo off
rem find DBXML_HOME
rem if not "%DBXML_HOME%"=="" goto checkJava

rem check for ant in Program Files on system drive
if not exist "%SystemDrive%\Program Files\dbXML-Core" goto checkSystemDrive
set DBXML_HOME=%SystemDrive%\Program Files\dbXML-Core
goto checkJava

:checkSystemDrive
rem check for ant in root directory of system drive
if not exist "%SystemDrive%\dbXML-Core" goto checkdbXML
set DBXML_HOME=%SystemDrive%\dbXML-Core
goto checkJava

:checkdbXML
rem check for ant in root directory of system drive
if not exist "%SystemDrive%\dbXML-Core" goto checkdbXMLWork
set DBXML_HOME=%SystemDrive%\dbXML-Core
goto checkJava


:checkdbXMLWork
rem check for ant in root directory of system drive
if not exist "%SystemDrive%\work\dbXML-Core" goto checkCurrent
set DBXML_HOME=%SystemDrive%\work\dbXML-Core
goto checkJava

:checkCurrent
if exist ".\config" set DBXML_HOME=
echo %DBXML_HOME%
goto checkJava

:noAntHome
echo DBXML_HOME is not set and ant could not be located. Please set DBXML_HOME.
goto end

:checkJava
if "%JAVACMD%" == "" set JAVACMD=java

set LOCALCLASSPATH=%CLASSPATH%
for %%i in (%DBXML_HOME%\java\lib\*.jar) do call %DBXML_HOME%\bin\lcp.bat %%i

if "%JAVA_HOME%" == "" goto runAnt
if exist %JAVA_HOME%\lib\tools.jar call %DBXML_HOME%\bin\lcp.bat %JAVA_HOME%\lib\tools.jar
if exist %JAVA_HOME%\lib\classes.zip call %DBXML_HOME%\bin\lcp.bat %JAVA_HOME%\lib\classes.zip

:runAnt
%JAVACMD% -classpath %LOCALCLASSPATH% %1 %2 %3 %4 %5 %6 %7 %8 %9

:end
set LOCALCLASSPATH=

