Files
electron-4/resources/java/stop.bat
2025-09-11 18:27:56 +08:00

39 lines
1.0 KiB
Batchfile
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

@echo off
chcp 65001 > nul
setlocal enabledelayedexpansion
set "CURRENT_DIR=%~dp0"
:: 核心配置
set "TARGET_JARS=yjearth.jar geographysdk.jar"
set "JPS_EXE=%CURRENT_DIR%jdk\bin\jps.exe"
set "TEMP_FILE=%temp%\jps_output.txt"
:: 检查jps可用性
if not exist "!JPS_EXE!" (
echo 错误未找到jps.exe!JPS_EXE!
endlocal && pause && exit /b 1
)
:: 获取Java进程列表
"!JPS_EXE!" -l > "!TEMP_FILE!" 2>nul
echo 正在查找运行中的进程...
:: 循环停止目标JAR
for %%J in (!TARGET_JARS!) do (
set "PID="
echo. && echo 查找 %%J 进程...
:: 匹配进程ID
for /f "tokens=1,2" %%a in ('type "!TEMP_FILE!"') do (
echo "%%b" | findstr /i "%%J" >nul && set "PID=%%a"
)
:: 终止逻辑
if defined PID (
taskkill /pid !PID! /f > nul 2>&1
if !errorlevel! equ 0 (echo 成功终止 %%JPID:!PID!) else (echo 终止 %%JPID:!PID!)失败)
) else (echo 未找到运行中的 %%J 进程)
)
:: 清理临时文件
del "!TEMP_FILE!" >nul 2>&1
echo. && echo 操作完成
endlocal && pause