@echo off

set QUERY=HKLM\Software\Hiperscan
if "%PROCESSOR_ARCHITECTURE%" == "AMD64" set QUERY=HKLM\Software\Wow6432Node\Hiperscan

set CURRENTQSVERSION=
set TMP=
set /a "x = 3"

:loop1

for /f "tokens=%x%" %%i in ('reg query "%QUERY%\CurrentQSVersion" /v VersionKey') do set TMP=%%i

if NOT "%TMP%." == "." (

	if "%CURRENTQSVERSION%." == "." (
		set "CURRENTQSVERSION=%TMP%"
	) else (
		set "CURRENTQSVERSION=%CURRENTQSVERSION% %TMP%"
	)

	set /a "x = x + 1"
	set TMP=
	goto :loop1
)

set QUERY=%QUERY%\%CURRENTQSVERSION%


set INSTALLPATH=
set TMP=
set /a "x = 3"

:loop2

for /f "tokens=%x%" %%i in ('reg query "%QUERY%" /v InstallPath') do set TMP=%%i

if NOT "%TMP%." == "." (

	if "%INSTALLPATH%." == "." (
		set "INSTALLPATH=%TMP%"
	) else (
		set "INSTALLPATH=%INSTALLPATH% %TMP%"
	)

	set /a "x = x + 1"
	set TMP=
	goto :loop2
)

set "MONOEXE=%INSTALLPATH%Mono\bin\Mono.exe"
set "CERTIFICATEPATH=%INSTALLPATH%Plugins\ApoIdent\UpdateCertificate.exe"

set MONO_PATH=
for /d %%i in ( "%INSTALLPATH%Mono\lib\mono\*" ) do set MONO_PATH=%%i


set MONO_PATH=%MONO_PATH%;%INSTALLPATH%HCL

"%MONOEXE%" "%CERTIFICATEPATH%"

