Files
status-indicators/remote-access/start-vista-newest.ps1
T

33 lines
2.0 KiB
PowerShell
Raw Normal View History

# start-vista-newest.ps1 - the status panel's "Start Vista" task on a Lighting PC: Vista opens the
# newest copy of the location's show, through Vista's own autoload preference (as North Attleboro's
# Vista opens Prop Takeover). Southcoast keeps several copies of "Tiverton Lighting.v3s"; the user
# chose "whichever is newest" (2026-10-21). Autosave backups (_Backups) are never picked.
#
# Installed at C:\ProgramData\StatusPanel\start-vista.ps1; the task runs
# powershell.exe -NoProfile -WindowStyle Hidden -ExecutionPolicy Bypass -File C:\ProgramData\StatusPanel\start-vista.ps1 -Show "Tiverton Lighting.v3s"
# A running Vista is left alone: its show is never changed under it.
param(
[string]$Show = "Tiverton Lighting.v3s",
[string]$Vista = "C:\Program Files (x86)\Chroma-Q\Vista3\Vista.exe",
[switch]$WhatIf
)
if ((Get-Process -Name Vista -ErrorAction SilentlyContinue) -and -not $WhatIf) { "Vista is running: left alone"; exit 0 }
$roots = @("$env:USERPROFILE\Desktop", "$env:USERPROFILE\Documents") | Where-Object { Test-Path $_ }
$newest = Get-ChildItem -Path $roots -Recurse -Filter $Show -File -ErrorAction SilentlyContinue |
Where-Object { $_.FullName -notmatch '\\_Backups\\' } | Sort-Object LastWriteTime -Descending | Select-Object -First 1
$prefs = "$env:USERPROFILE\Documents\Vista 3\.preferences"
if ($newest -and (Test-Path $prefs)) {
$text = [IO.File]::ReadAllText($prefs)
$line = '<autoloadpath>' + [Security.SecurityElement]::Escape($newest.FullName) + '</autoloadpath>'
$new = [regex]::Replace($text, '<autoloadpath>.*?</autoloadpath>', [Text.RegularExpressions.MatchEvaluator]{ param($m) $line })
"newest: $($newest.FullName) ($($newest.LastWriteTime))"
if ($new -ne $text -and -not $WhatIf) {
Copy-Item $prefs "$prefs.before-status-panel" -Force
[IO.File]::WriteAllText($prefs, $new)
"autoload set"
}
} else {
"no $Show found, or no Vista preferences: Vista starts with its own choice"
}
if (-not $WhatIf) { Start-Process -FilePath $Vista -WorkingDirectory (Split-Path $Vista) }