improve stop script with better error handling

This commit is contained in:
祀梦
2026-01-27 21:50:46 +08:00
parent 74fa0c60ad
commit c55793bae5
2 changed files with 48 additions and 3 deletions

View File

@@ -3,7 +3,6 @@ chcp 65001 >nul
setlocal
cd /d %~dp0
REM Stop processes using PowerShell
powershell -ExecutionPolicy Bypass -Command "& { Write-Host 'Stopping processes on 8923 and 6173...' -ForegroundColor Cyan; $ports = @(8923, 6173); foreach ($port in $ports) { $p = Get-NetTCPConnection -LocalPort $port -ErrorAction SilentlyContinue; if ($p) { Stop-Process -Id $p.OwningProcess -Force; Write-Host \"Stopped port $port\" } }; Write-Host 'Done.' -ForegroundColor Green }"
powershell -ExecutionPolicy Bypass -File stop.ps1
timeout /t 2
pause