11 lines
750 B
Batchfile
11 lines
750 B
Batchfile
@echo off
|
|
title Stop ZCode AI engine (chengtao-baojia)
|
|
rem Kill the engine process listening on the configured port. (same as silent variant, with pause)
|
|
rem Port: %USERPROFILE%\.zcode\chengtao\port.txt (fallback 18789)
|
|
setlocal
|
|
set "PORT=18789"
|
|
if exist "%USERPROFILE%\.zcode\chengtao\port.txt" set /p PORT=<"%USERPROFILE%\.zcode\chengtao\port.txt"
|
|
powershell -NoProfile -Command "$conns = Get-NetTCPConnection -LocalPort %PORT% -State Listen -ErrorAction SilentlyContinue; if (-not $conns) { Write-Host ('port ' + %PORT% + ' has no running engine') } else { $conns | Select-Object -ExpandProperty OwningProcess -Unique | ForEach-Object { Write-Host ('stop PID ' + $_); Stop-Process -Id $_ -Force -ErrorAction SilentlyContinue } }"
|
|
echo Done.
|
|
pause
|