@echo OFF

setlocal  enabledelayedexpansion 

cls
echo.


set envFileName=..\config\XCI_3DX_BATCH_Env.txt
if not "%~1" == "" (
	set envFileName=%~1
)

if not exist "%envFileName%" (
	echo.
	echo. Cannot find %envFileName%
	echo.
	pause
	endlocal
	exit
)
echo.
set envFileNameAbsolute=""
call :ABSOLUTE_PATH envFileNameAbsolute "%envFileName%"

echo.   3DExperience environment file:
echo.   %envFileNameAbsolute%
echo.   Log file:
echo.   %temp%\XCIInstallationCheck.log 

echo.
echo.   starting "Check Server Connection" ...


for /f "usebackq tokens=*" %%i in (`FINDSTR "^PATH=" "%envFileName%"`) do (
	call set %%i
)
echo.
echo.
catstart -env "%envFileName%" -run "XCIInstallationCheck -check" 2>"%temp%\XCIInstallationCheck.log"

echo.
echo.
pause
endlocal

exit /b

:: Build absolute path out of relative path
:ABSOLUTE_PATH
SET %1=%~f2
exit /b