wechat_ai/wechat_vision/stop_wechat_algorithm_live_windows.ps1

27 lines
813 B
PowerShell

$ErrorActionPreference = 'Stop'
Set-Location -Path $PSScriptRoot
$pidFile = Join-Path $PSScriptRoot 'ouptsw/wechat_algorithm_live.pid'
if (-not (Test-Path $pidFile)) {
Write-Host 'WeChat algorithm live monitor is not running: pid file missing'
exit 0
}
$pidText = (Get-Content $pidFile -Raw).Trim()
if (-not $pidText) {
Remove-Item $pidFile -Force -ErrorAction SilentlyContinue
Write-Host 'WeChat algorithm live monitor is not running: pid file empty'
exit 0
}
$process = Get-Process -Id ([int]$pidText) -ErrorAction SilentlyContinue
if ($process) {
Stop-Process -Id $process.Id -Force
Write-Host "WeChat algorithm live monitor stopped: pid=$pidText"
} else {
Write-Host "WeChat algorithm live monitor is not running: pid=$pidText"
}
Remove-Item $pidFile -Force -ErrorAction SilentlyContinue