[关闭]
@cyysu 2017-10-12T10:19:44.000000Z 字数 1959 阅读 902

Bat-实战基础篇(五)

  • 时间:2017年10月11日
  • 作者:Kali
  • 邮箱:cyysu.github.io@gmail.com/2869905223@qq.com/微信lwyx1413
  • 版本:4.0
  • 描述:批处理实战基础篇五,主要讲解tomcat下启动脚本,本文主要讲解startup.bat这个脚本

Bat系列教程


项目实战

  1. # startup.bat
  2. @echo off
  3. rem Licensed to the Apache Software Foundation (ASF) under one or more
  4. rem contributor license agreements. See the NOTICE file distributed with
  5. rem this work for additional information regarding copyright ownership.
  6. rem The ASF licenses this file to You under the Apache License, Version 2.0
  7. rem (the "License"); you may not use this file except in compliance with
  8. rem the License. You may obtain a copy of the License at
  9. rem
  10. rem http://www.apache.org/licenses/LICENSE-2.0
  11. rem
  12. rem Unless required by applicable law or agreed to in writing, software
  13. rem distributed under the License is distributed on an "AS IS" BASIS,
  14. rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. rem See the License for the specific language governing permissions and
  16. rem limitations under the License.
  17. rem ---------------------------------------------------------------------------
  18. rem Start script for the CATALINA Server
  19. rem ---------------------------------------------------------------------------
  20. :: 设置批处理开始改变本地操作,批处理结束时自动调用endlocal,所做的环境变量变成原来的,也就是作用域仅限于脚本中
  21. setlocal
  22. rem Guess CATALINA_HOME if not defined
  23. set "CURRENT_DIR=%cd%"
  24. if not "%CATALINA_HOME%" == "" goto gotHome
  25. set "CATALINA_HOME=%CURRENT_DIR%"
  26. if exist "%CATALINA_HOME%\bin\catalina.bat" goto okHome
  27. cd ..
  28. set "CATALINA_HOME=%cd%"
  29. cd "%CURRENT_DIR%"
  30. :gotHome
  31. if exist "%CATALINA_HOME%\bin\catalina.bat" goto okHome
  32. echo The CATALINA_HOME environment variable is not defined correctly
  33. echo This environment variable is needed to run this program
  34. goto end
  35. :okHome
  36. set "EXECUTABLE=%CATALINA_HOME%\bin\catalina.bat"
  37. rem Check that target executable exists
  38. if exist "%EXECUTABLE%" goto okExec
  39. echo Cannot find "%EXECUTABLE%"
  40. echo This file is needed to run this program
  41. goto end
  42. :okExec
  43. rem Get remaining unshifted command line arguments and save them in the
  44. set CMD_LINE_ARGS=
  45. :setArgs
  46. if ""%1""=="""" goto doneSetArgs
  47. set CMD_LINE_ARGS=%CMD_LINE_ARGS% %1
  48. shift
  49. goto setArgs
  50. :doneSetArgs
  51. :: 调用其他批处理脚本
  52. call "%EXECUTABLE%" start %CMD_LINE_ARGS%
  53. :end

打赏

                    支付宝                                                         微信

微信与支付宝支付

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注