当前位置:   article > 正文

window脚本启动或停止jar包_windows jar 启动 停止脚本

windows jar 启动 停止脚本
  1. @echo off
  2. set operation=%1
  3. set jarName=%2
  4. if "%operation%"=="start" (
  5. echo "Start %jarName% ..."
  6. start javaw -jar %jarName%
  7. echo "Start %jarName% Success..."
  8. jps -l|findStr "%jarName%"
  9. ) else if "%operation%"=="stop" (
  10. echo "Stop %jarName%"
  11. for /f "usebackq tokens=1-2" %%a in (`jps -l ^| findstr %jarName%`) do (
  12. taskkill /f /pid %%a
  13. )
  14. echo "Stop %jarName% Success..."
  15. ) else if "%operation%"=="restart" (
  16. echo "ReStart %jarName% ..."
  17. for /f "usebackq tokens=1-2" %%a in (`jps -l ^| findstr %jarName%`) do (
  18. taskkill /f /pid %%a
  19. echo "Restart %jarName% ..."
  20. start javaw -jar %jarName%
  21. jps -l|findStr "%jarName%"
  22. )
  23. echo "Restart %jarName% Success..."
  24. ) else if "%operation%"=="status" (
  25. jps -l|findStr "%jarName%"
  26. ) else (
  27. echo "Usage: execJar.bat [start|stop|restart|status]"
  28. )

停止jar包

  1. @echo off
  2. set program=%1
  3. echo program: %program%
  4. for /f "usebackq tokens=1-2" %%a in (`jps -l ^| findstr %program%`) do (
  5. taskkill /f /pid %pid%
  6. )

启动jar包

  1. @echo off
  2. start javaw -jar %1
  3. jps -l|findStr %1

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/weixin_40725706/article/detail/76278
推荐阅读
相关标签
  

闽ICP备14008679号