47 lines
1.6 KiB
PowerShell
47 lines
1.6 KiB
PowerShell
# ProxyPool Stop Script
|
|
$rootPath = Split-Path $PSScriptRoot -Parent
|
|
|
|
Write-Host "=== Stopping ProxyPool Services ===" -ForegroundColor Cyan
|
|
Write-Host ""
|
|
|
|
Write-Host "[1/2] Stopping processes on ports 8923 and 6173..." -ForegroundColor Cyan
|
|
$ports = @(8923, 6173)
|
|
$stoppedCount = 0
|
|
|
|
foreach ($port in $ports) {
|
|
try {
|
|
$conn = Get-NetTCPConnection -LocalPort $port -ErrorAction SilentlyContinue
|
|
if ($conn) {
|
|
$processId = $conn.OwningProcess
|
|
|
|
try {
|
|
$process = Get-Process -Id $processId -ErrorAction SilentlyContinue
|
|
if ($process) {
|
|
$processName = $process.ProcessName
|
|
Stop-Process -Id $processId -Force -ErrorAction SilentlyContinue
|
|
|
|
Write-Host " Stopped port $port (PID: $processId, Process: $processName)" -ForegroundColor Gray
|
|
$stoppedCount++
|
|
}
|
|
} catch {
|
|
Write-Host " Warning: Could not stop process on port $port (PID: $processId)" -ForegroundColor Yellow
|
|
}
|
|
} else {
|
|
Write-Host " Port $port: No process found" -ForegroundColor DarkGray
|
|
}
|
|
} catch {
|
|
Write-Host " Error checking port $port: $($_.Exception.Message)" -ForegroundColor Red
|
|
}
|
|
}
|
|
|
|
Write-Host " Stopped $stoppedCount process(es)" -ForegroundColor Green
|
|
Write-Host ""
|
|
|
|
Write-Host "[2/2] Waiting for processes to fully stop..." -ForegroundColor Cyan
|
|
Start-Sleep -Seconds 2
|
|
|
|
Write-Host ""
|
|
Write-Host "=== Done ===" -ForegroundColor Cyan
|
|
Write-Host "All services have been stopped." -ForegroundColor Green
|
|
Write-Host ""
|