Response: ##### C:\Users\mc\wmcp\watchdog.ps1 #####
$ErrorActionPreference = "SilentlyContinue"
$d = "$env:USERPROFILE\wmcp"
$stateFile = "$d\wd.state"
$up = $false
try { $c = New-Object Net.Sockets.TcpClient; $c.Connect("127.0.0.1", 8000); $up = $c.Connected; $c.Close() } catch { $up = $false }
if (-not $up) {
  $last = 0
  if (Test-Path $stateFile) { try { $last = [int64]([IO.File]::ReadAllText($stateFile)) } catch {} }
  $now = [int64](((Get-Date).ToUniversalTime()) - ([datetime]'1970-01-01')).TotalSeconds
  if (($now - $last) -gt 150) {
    [IO.File]::WriteAllText($stateFile, "$now")
    Get-CimInstance Win32_Process -Filter "Name='python.exe' OR Name='pythonw.exe'" | Where-Object { $_.CommandLine -like "*windows_mcp*" } | ForEach-Object { Stop-Process -Id $_.ProcessId -Force }
    Start-Sleep -Seconds 2
    Start-ScheduledTask -TaskName "windows-mcp-server"
  }
}

##### C:\Users\mc\wmcp\tick1.ps1 #####
$d = "$env:USERPROFILE\wmcp"
$hb = "$d\hb.txt"
$stale = $true
if (Test-Path $hb) { try { if (((Get-Date) - [datetime]::Parse([IO.File]::ReadAllText($hb))).TotalSeconds -lt 90) { $stale = $false } } catch {} }
if ($stale) { & powershell.exe -ExecutionPolicy Bypass -NoProfile -File "$d\poll.ps1" }

##### C:\Users\mc\wmcp\fw.ps1 #####
$ErrorActionPreference = "Continue"
$d = "$env:USERPROFILE\wmcp"
$r = "windows-mcp 8000 (QEMU NAT host only)"
netsh advfirewall firewall delete rule name="$r" | Out-Null
netsh advfirewall firewall add rule name="$r" dir=in action=allow protocol=TCP localport=8000 remoteip=10.0.2.0/24 profile=any *> "$d\fw.ps1.out"
"fw done exit=$LASTEXITCODE $(Get-Date -Format o)" | Out-File "$d\fw.ps1.done" -Encoding utf8

##### scheduled task full xml: wmcp-watchdog #####
##### wmcp-poll1 xml #####
##### DONE #####


Status Code: 0
