-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathstop_remote_stack.cmd
More file actions
36 lines (32 loc) · 1.33 KB
/
stop_remote_stack.cmd
File metadata and controls
36 lines (32 loc) · 1.33 KB
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
28
29
30
31
32
33
34
35
36
@echo off
setlocal
echo.
echo Stopping local CodeClaw remote stack...
echo.
powershell -NoProfile -ExecutionPolicy Bypass -Command ^
"$ErrorActionPreference = 'SilentlyContinue';" ^
"$windowPatterns = @('CodeClaw Hub Center*', 'CodeClaw Hub*');" ^
"foreach ($pattern in $windowPatterns) {" ^
" taskkill /FI ('WINDOWTITLE eq ' + $pattern) /T /F | Out-Null" ^
"}" ^
"$targets = @(@{ Port = 9388; Label = 'CodeClaw Hub Center' }, @{ Port = 9399; Label = 'CodeClaw Hub' });" ^
"foreach ($target in $targets) {" ^
" $pids = Get-NetTCPConnection -State Listen -LocalPort $target.Port -ErrorAction SilentlyContinue | Select-Object -ExpandProperty OwningProcess -Unique;" ^
" if (-not $pids) {" ^
" Write-Host ('[INFO] No listening process found on port ' + $target.Port + '.');" ^
" continue" ^
" }" ^
" foreach ($procId in $pids) {" ^
" try {" ^
" Stop-Process -Id $procId -Force -ErrorAction Stop;" ^
" Write-Host ('[OK] Stopped ' + $target.Label + ' process on port ' + $target.Port + ' (PID ' + $procId + ').');" ^
" } catch {" ^
" Write-Host ('[WARN] Failed to stop ' + $target.Label + ' process on port ' + $target.Port + ' (PID ' + $procId + '): ' + $_.Exception.Message);" ^
" }" ^
" }" ^
"}"
echo.
echo CodeClaw remote stack stop sequence finished.
echo.
endlocal
exit /b 0