windows使用脚本启动停止jar包
启动脚本
@echo off
::set path=C:\Program Files\Java\jdk1.8.0_261\bin\
::start C:\"Program Files"\Java\jdk1.8.0_261\bin\javaw -jar d:\java\com-cjmlweb-cms.jar
C:\"Program Files"\Java\jdk1.8.0_261\bin\javaw -jar "d:\java\com-cjmlweb-cms.jar"
exit 0
停止脚本
@echo off
taskkill /f /im javaw.exe
exit 0
自动寻找相应对口,并关闭相关进程
@echo off
chcp 65001
set port=8081
for /f "tokens=1-5" %%i in ('netstat -ano^|findstr ":%port%"') do (
echo kill the process %%m who use the port %port%
echo 正在关闭,请等待 %%m
taskkill /f /pid %%m
)
Pause