windows停止和启动jar
启动
chcp 65001
@echo off
if "%1" == "h" goto begin
mshta vbscript:createobject("wscript.shell").run("%~nx0 h",0)(window.close)&&exit
:begin
java -Dfile.encoding=utf-8 -jar E:\net_hospital\blade-api.jar --spring.profiles.active=prod --server.port=8888 > E:\net_hospital\log.log 2>&1 &
停止
@echo off
set ports=8888
setlocal enabledelayedexpansion
(
for %%P in (%ports%) do (
echo %%P start
for /f "delims= tokens=1" %%i in ('netstat -aon ^| findstr "%%P %"') do (
set a=%%i
taskkill /f /pid "!a:~71,5!"
)
echo %%P end
)
)
pause>nul