-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstop.ps1
More file actions
27 lines (22 loc) · 726 Bytes
/
Copy pathstop.ps1
File metadata and controls
27 lines (22 loc) · 726 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"
Set-Location $PSScriptRoot
$port = 8060
if ($env:CURSOR_WEB_PORT) {
$port = [int]$env:CURSOR_WEB_PORT
}
$listeners = Get-NetTCPConnection -LocalPort $port -ErrorAction SilentlyContinue
if (-not $listeners) {
Write-Host "Kein Prozess auf Port $port."
exit 0
}
$pids = $listeners | Select-Object -ExpandProperty OwningProcess -Unique
foreach ($procId in $pids) {
if ($procId -eq 0) { continue }
$proc = Get-Process -Id $procId -ErrorAction SilentlyContinue
if ($proc) {
Write-Host "Beende $($proc.ProcessName) (PID $procId) auf Port $port..."
Stop-Process -Id $procId -Force
}
}
Write-Host "Port $port frei. Start mit: .\start.ps1"