Win系统Java启停脚本
1.start.bat
修改JAVA_HOME、JAR_NAME以及JAR_LOG_PATH
chcp 65001
@echo off
title demo
%1 mshta vbscript:CreateObject("WScript.Shell").Run("%~s0 ::",0,FALSE)(window.close)&&exit
set JAVA_HOME=D:\Toolkit\JDK\jdk-1.8
set JAR_NAME=D:\Temp\ding\local-file-0.0.1-SNAPSHOT.jar
set JAR_LOG_PATH=D:\Temp\ding\run.log
%JAVA_HOME%/bin/java -jar %JAR_NAME% > %JAR_LOG_PATH% 2>&1 &
exit
2.stop.sh
修改9596为需要关闭的目的端口
CHCP 65001
@echo off & setlocal EnableDelayedExpansion
set obj[0]=9596
set port=0
set pid=0
echo ==================== 端口号查杀工具 ========================
for /f "usebackq delims== tokens=1-2" %%a in (`set obj`) do (
set port=%%b
echo 开始查找端口号【!port!】所占用进程
for /f "tokens=5" %%m in ('netstat -aon ^| findstr ":%%b"') do (
set pid=%%m
)
if "!pid!"=="0" (
echo 端口号【!port!】没有占用
) else (
echo 端口号【!port!】相关进程已杀死
taskkill /f /pid !pid!
)
set pid=0
)
pause