@echo off
setlocal EnableExtensions EnableDelayedExpansion
cls
Echo.
Echo.
Echo.
Echo    Please wait while loading the JavaPos POSTest application .....
Echo.
Echo.

if /i {%PROCESSOR_ARCHITECTURE%} == {AMD64} set path=%windir%\SysWow64;%path%

set javakey=HKLM\SOFTWARE\JavaSoft\Java Development Kit
for /F "tokens=1,2*" %%i in ('reg.exe query "%javakey%" /v CurrentVersion 2^>nul') DO (
 if /i "%%i"=="CurrentVersion" (
  for /F "tokens=1,2*" %%a in ('reg.exe query "%javakey%\%%k"  /v JavaHome  2^>nul') DO (
   if /i "%%a"=="JavaHome" (
		if not defined JAVA_HOME set JAVA_HOME=%%c
		set path=%%c\bin;!path!
   )
  )
 )
)

set javakey=HKLM\SOFTWARE\JavaSoft\Java Runtime Environment
for /F "tokens=1,2*" %%i in ('reg.exe query "%javakey%" /v CurrentVersion 2^>nul') DO (
 if /i "%%i"=="CurrentVersion" (
  for /F "tokens=1,2*" %%a in ('reg.exe query "%javakey%\%%k"  /v JavaHome  2^>nul') DO (
   if /i "%%a"=="JavaHome" (
   		if not defined JRE_HOME set JRE_HOME=%%c
		set path=%%c\bin;!path!
   )
  )
 )
)

cd /d %~dp0
set oldcp=%classpath%
set classpath=postest.jar
set classpath=%classpath%;jpos114.jar
set classpath=%classpath%;jna-4.2.1.jar
set classpath=%classpath%;jna-platform-4.2.1.jar
set classpath=%classpath%;xercesImpl.jar
set classpath=%classpath%;"%cd%"\

REM Modify the following line to point to the directories containing ScannerJni.dll
PATH=%PATH%;%cd%\scannerso

REM Archives containing the JPOS controls
set classpath=%classpath%;"%cd%"\jpos\jpos114-controls.jar
set classpath=%classpath%;"%cd%"\scannerso\scannerjpos.jar
set classpath=%classpath%;"%cd%"\scannerso\log4j-api-2.17.1.jar;"%cd%"\scannerso\log4j-core-2.17.1.jar


rem java -cp %classpath% -Djava.library.path=%lp% com.jpos.POStest.POStest
java -XX:+ShowMessageBoxOnError -cp %classpath%  com.jpos.POStest.POStest  || (color 2f & echo. & pause)
set classpath=%oldcp%
