Files
riojoy/deploy/install-rio.ps1
T
CydandClaude Opus 4.8 d17fd018eb Add cockpit deployment package + single-instance guard
deploy/ builds a single zip for TeslaConsole: the self-contained tray app and
the signed ViGEmBus installer under a riojoy\ folder, with postinstall.bat at the
root. postinstall elevates and runs riojoy\install-rio.ps1, which installs
ViGEmBus silently (if absent) and registers RIOJoy to start at logon — no cert
trust, test signing, Secure Boot change, or reboot.

Also guard against two instances fighting over the COM port (machine-wide +
per-user autostart both firing): a per-session named mutex makes a second launch
exit immediately. Built zips (dist/) and the bundled installer (deploy/vendor/)
are git-ignored.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-29 09:29:01 -05:00

76 lines
3.3 KiB
PowerShell

<#
.SYNOPSIS
RIOJoy cockpit post-install. Installs the signed ViGEmBus virtual-controller
driver (if absent) and sets RIOJoy to start at logon. Must run elevated
(postinstall.bat elevates for you). Idempotent — safe to re-run.
.DESCRIPTION
Run from inside the deployed package directory (e.g. C:\games\RIOJOY). Paths
are resolved relative to this script, so the layout is:
<root>\app\RioJoy.Tray.exe the published tray app (self-contained)
<root>\vendor\ViGEmBus_*.exe the signed ViGEmBus installer
<root>\install-rio.ps1 (this file)
ViGEmBus is WHQL/attestation-signed: it installs with NO test signing, NO
Secure Boot change, and NO reboot. The RIO appears to games as a standard
Xbox 360 controller.
.PARAMETER NoLaunch
Do not start the app after install (it still starts at the next logon).
#>
param([switch]$NoLaunch)
$ErrorActionPreference = 'Stop'
$root = $PSScriptRoot
$appExe = Join-Path $root 'app\RioJoy.Tray.exe'
$vendorDir = Join-Path $root 'vendor'
$runValueName = 'RIOJoy'
# --- guards ---------------------------------------------------------------
$principal = [Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()
if (-not $principal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
throw 'install-rio.ps1 must run elevated. Run postinstall.bat (it elevates).'
}
if (-not (Test-Path $appExe)) { throw "App not found: $appExe (is the package complete?)." }
Write-Host '== RIOJoy post-install ==' -ForegroundColor Cyan
# 1. Install ViGEmBus if its driver service is not already present.
$svc = Get-Service -Name ViGEmBus -ErrorAction SilentlyContinue
if ($svc) {
Write-Host "ViGEmBus already installed (service is $($svc.Status))."
} else {
$installer = Get-ChildItem -Path $vendorDir -Filter 'ViGEmBus*.exe' -ErrorAction SilentlyContinue |
Select-Object -First 1
if ($installer) {
Write-Host "Installing ViGEmBus ($($installer.Name))..."
$p = Start-Process -FilePath $installer.FullName `
-ArgumentList '/install', '/quiet', '/norestart' -Wait -PassThru
if ($p.ExitCode -notin 0, 3010) {
throw "ViGEmBus install failed (exit code $($p.ExitCode))."
}
Write-Host 'ViGEmBus installed.'
} else {
Write-Warning "ViGEmBus installer not found in $vendorDir — joystick output will be"
Write-Warning "unavailable until ViGEmBus is installed (keyboard/mouse still work)."
}
}
# 2. Start RIOJoy at logon (machine-wide Run key -> runs in each user's session).
Write-Host 'Registering RIOJoy to start at logon...'
$runKey = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Run'
New-ItemProperty -Path $runKey -Name $runValueName -Value "`"$appExe`"" -PropertyType String -Force | Out-Null
# --- summary --------------------------------------------------------------
Write-Host ''
Write-Host "RIOJoy installed to $root" -ForegroundColor Green
Write-Host 'RIOJoy starts automatically at logon.'
if (-not $NoLaunch) {
Write-Host 'Launching RIOJoy...'
# Launch via explorer so the tray app runs de-elevated in the user session.
Start-Process -FilePath (Join-Path $env:WINDIR 'explorer.exe') -ArgumentList $appExe
}
exit 0