<# .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: \app\RioJoy.Tray.exe the published tray app (self-contained) \vendor\ViGEmBus_*.exe the signed ViGEmBus installer \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