important page: http://www.robvanderwoude.com/for.php
some explanation in the below example:
for /f %%i in ('dir /b /on %exchangesim_home%\lib\exchangesim-*.jar') do set exchangesim_jar_file=%exchangesim_home%\lib\%%i
this code won't work as you think. The reason is because, %exchangesim_home% will be explained as soon as the command start. So, it will look like:
exchangesim_jar_file=.\lib\%%i
The workaround is, like this:
=================================================
in env-viperooe.bat
set VIPEROOE_CLASSPATH=.
for /f %%i in ('dir /b /on .\lib\*.jar') do set-viperooe_classpath.bat %%i
echo %VIPEROOE_CLASSPATH%
in set-viperooe_classpath.bat
set VIPEROOE_CLASSPATH=%VIPEROOE_CLASSPATH%;.\lib\%1
=
================================================
@echo offsetlocal
set exchangesim_home=%~dp0
call %exchangesim_home%\env-exchangesim.bat
set instancename=fooset jflags=-ms64M -mx1024M -Xnoclassgcset mainclass=com.citigroup.get.quantum.lifecycle.LifeCycleManager
set tt_lic=%TT_HOME%\license\tcm.licset classpath=%classpath%;configset classpath=%classpath%;%EXCHANGESIM_CLASSPATH%
set opts=%opts% -Djava.library.path=%LD_LIBRARY_PATH%
set opts=%opts% -Djava.util.logging.config.file=config\logging.properties
set opts=%opts% -Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.Jdk14Logger
set opts=%opts% -Djava.security.policy=config\allperms.policy
set opts=%opts% -Dtt.licensefile=%tt_lic%
set opts=%opts% -Dviperooe.instance=%instancename%
for /f %%i in ('dir /b /on %exchangesim_home%\lib\exchangesim-*.jar') do set exchangesim_jar_file=%exchangesim_home%\lib\%%i
mkdir %exchangesim_home%\config\exchangesim\%instancename% 2> nul
start "exchangesim - %instancename%" /D%exchangesim_home% %JAVA_HOME%/bin/java %jflags% -classpath %classpath%;%exchangesim_jar_file% %opts% %mainclass% config
exchangesim %instancename%endlocal