# Thin Windows launcher for the cross-platform Python agent. # Prefer: python send_sysinfo.py # This script only finds Python and forwards args. # # Usage: # .\send_sysinfo.ps1 # .\send_sysinfo.ps1 -Port COM5 # .\send_sysinfo.ps1 -Port COM5 -IntervalMs 1000 param( [string]$Port = "", [int]$IntervalMs = 1000, [int]$Baud = 460800 ) $ErrorActionPreference = "Stop" $here = Split-Path -Parent $MyInvocation.MyCommand.Path $pyScript = Join-Path $here "send_sysinfo.py" function Find-Python { foreach ($c in @( "python", "py", (Join-Path $env:USERPROFILE "AppData\Local\Programs\Python\Python312\python.exe"), (Join-Path $env:USERPROFILE "AppData\Local\Programs\Python\Python311\python.exe") )) { if (-not $c) { continue } if ($c -eq "py") { $cmd = Get-Command py -ErrorAction SilentlyContinue if ($cmd) { return @($cmd.Source, "-3") } continue } $cmd = Get-Command $c -ErrorAction SilentlyContinue if ($cmd) { return @($cmd.Source) } if (Test-Path $c) { return @($c) } } return $null } $py = Find-Python if (-not $py) { throw "Python not found. Install Python 3.8+ then: pip install -r requirements.txt" } & $py[0] @($py[1..($py.Length-1)]) -c "import psutil,serial" 2>$null if ($LASTEXITCODE -ne 0) { Write-Host "Installing host deps..." & $py[0] @($py[1..($py.Length-1)]) -m pip install -r (Join-Path $here "requirements.txt") & $py[0] @($py[1..($py.Length-1)]) -m pip install nvidia-ml-py } $argv = @($pyScript, "--baud", "$Baud", "--interval-ms", "$IntervalMs") if ($Port) { $argv += @("--port", $Port) } Write-Host "Launch: $($py -join ' ') $($argv -join ' ')" & $py[0] @($py[1..($py.Length-1)]) @argv exit $LASTEXITCODE