@echo OFF

rem Open command prompt using batch environment
rem
rem When used without arguments, this tool uses the default 3DExperience environment file:
rem ..\config\XCI_3DX_BATCH_Env.txt
rem To use a different environment file you can pass the full path of the environment file as
rem as argument. It is also possible to drag and drop the environment file on this utility. 

setlocal  enabledelayedexpansion 

cls
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%


for /f "usebackq tokens=*" %%i in (`FINDSTR "^PATH=" "%envFileName%"`) do (
	call set %%i
)

catstart -env "%envFileName%" -run "cmd"

echo.
pause
endlocal

exit /b

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