侧边栏壁纸
博主头像
菠萝饭博主等级

懒人一枚

  • 累计撰写 29 篇文章
  • 累计创建 3 个标签
  • 累计收到 7 条评论

windows运行jar项目的bat命令

菠萝饭
2021-11-24 / 2 评论 / 2 点赞 / 105 阅读 / 827 字

最近用到了,现做简单总结:

启动
@echo off
%1 mshta vbscript:CreateObject("WScript.Shell").Run("%~s0 ::",0,FALSE)(window.close)&&exit
java -jar -Dfile.encoding=utf-8 eladmin-system-2.6.jar  >StartupLog.log  2>&1 &
exit

停止
@echo off
set port=8000
for /f "tokens=1-5" %%i in ('netstat -ano^|findstr ":%port%"') do (
    echo kill the process %%m who use the port 
    taskkill /pid %%m -t -f
    goto q
)
:q
重启
@echo off
set port=8000
for /f "tokens=1-5" %%i in ('netstat -ano^|findstr ":%port%"') do (
    echo kill the process %%m who use the port 
    taskkill /pid %%m -t -f
    goto start
)
:start
 
%1 mshta vbscript:CreateObject("WScript.Shell").Run("%~s0 ::",0,FALSE)(window.close)&&exit
java -jar -Dfile.encoding=utf-8 eladmin-system-2.6.jar  >StartupLog.log  2>&1 &
exit

0

评论区