bat-startup.bat解析
@echo off rem @echo off关闭回显 setlocal rem 将后面的环境变量设置为临时环境变量(直到endlocal 命令的出现)。 rem Guess CATALINA_HOME if not defined set "CURRENT_DIR=%cd%" rem %cd%代表当前目录,设置CURRENT_DIR等于当前目录 if not "%CATALINA_HOME%" == "" goto gotHome rem 如果获取%CATALINA_HOME%的值不等于空,转到:gotHome标签处,等于空(环境变量CATALINA_HOME值没有设置)继续往下执行 set "CATALINA_HOME=%CURRENT_DIR%" rem 设置CATALINA_HOME的值为当前目录 if exist "%CATALINA_HOME%\bin\catalina.bat" goto okHome rem 判断catalina.bat是否存在,存在转到:okHome,不存在往下执行 cd .. set "CATALINA_HOME=%cd%" cd "%CURRENT_DIR%" :gotHome if exist "%CATALINA_HOME%\bin\catalina.bat" goto okHome echo The CATALINA_HOME environment variable is not defined correctly echo This environment variable is needed to run this program goto end :okHome set "EXECUTABLE=%CATALINA_HOME%\bin\catalina.bat" rem Check that target executable exists if exist "%EXECUTABLE%" goto okExec echo Cannot find "%EXECUTABLE%" echo This file is needed to run this program goto end :okExec rem Get remaining unshifted command line arguments and save them in the set CMD_LINE_ARGS= :setArgs if ""%1""=="""" goto doneSetArgs rem 检查%1是否为空,如果为空就表示没有参数了,设置参数结束,转至doneSetArgs标签 set CMD_LINE_ARGS=%CMD_LINE_ARGS% %1 rem 如果不为空就把%1指向的参数追加到CMD_LINE_ARGS这个环境变量中。 shift rem 删除第一个参数,后面的参数左移一个位置。 goto setArgs :doneSetArgs call "%EXECUTABLE%" start %CMD_LINE_ARGS% rem 通过call命令调用catalina.bat启动脚本,并传递参数 :end