Files
serverinfotest/host/install_autostart.ps1
DESKTOP-PUHFO60\dsx2016 f83df3fd39 Ship Windows plug-and-play host exe with USB wait and autostart.
Users no longer need Python: run.bat or install_autostart.ps1; agent reconnects when CYD is plugged in.
2026-10-27 20:23:57 +08:00

33 lines
1.1 KiB
PowerShell

# Install "plug CYD USB and it just works" for the current Windows user.
# - Copies/uses host\send_sysinfo.exe
# - Adds a Startup-folder shortcut (runs at login, waits for USB serial)
$ErrorActionPreference = "Stop"
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
$exe = Join-Path $here "send_sysinfo.exe"
if (-not (Test-Path $exe)) {
Write-Host "Building send_sysinfo.exe first..."
& (Join-Path $here "build_exe.ps1")
}
if (-not (Test-Path $exe)) {
throw "send_sysinfo.exe missing. Run build_exe.ps1 first."
}
$startup = [Environment]::GetFolderPath("Startup")
$lnkPath = Join-Path $startup "CYD-ServerInfo.lnk"
$w = New-Object -ComObject WScript.Shell
$lnk = $w.CreateShortcut($lnkPath)
$lnk.TargetPath = $exe
$lnk.WorkingDirectory = $here
$lnk.WindowStyle = 7 # minimized
$lnk.Description = "CYD host sysinfo agent (waits for USB)"
$lnk.Save()
Write-Host "Autostart installed: $lnkPath"
Write-Host "Starting agent now..."
Start-Process -FilePath $exe -WorkingDirectory $here -WindowStyle Minimized
Write-Host "Done. Plug in CYD USB anytime — agent waits/reconnects automatically."
Write-Host "Remove later: .\uninstall_autostart.ps1"