Odin/scripts/stop-odin.ps1
2026-05-31 16:36:09 +01:00

22 lines
532 B
PowerShell

param(
[string] $StateDir = "E:\Projects\Odin\scratch\odin"
)
$ErrorActionPreference = "Stop"
$pidPath = Join-Path $StateDir "odin.pid"
if (-not (Test-Path $pidPath)) {
Write-Host "No Odin PID file found at $pidPath."
exit 0
}
$odinPid = (Get-Content -Raw $pidPath).Trim()
if ($odinPid -match "^\d+$") {
$process = Get-Process -Id ([int] $odinPid) -ErrorAction SilentlyContinue
if ($process) {
Stop-Process -Id $process.Id
Write-Host "Stopped Odin PID $odinPid."
}
}
Remove-Item -LiteralPath $pidPath -Force