Created
February 3, 2021 01:30
-
-
Save gdyr/3e3731cc55ccd55d972c9b8eb0823283 to your computer and use it in GitHub Desktop.
Automatically launch best Q-Sys Designer version for design file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Parse design file header | |
$header = [System.Text.Encoding]::ASCII.GetString((Get-Content $args[0] -Encoding byte -TotalCount 64)); | |
$version = ($header | Select-String -Pattern "Q-Sys Designer, Version=(\d+\.\d+)").Matches.Groups[1].Value; | |
# Enumerate installed Q-Sys Designer versions | |
$InstalledSoftware = Get-ChildItem "HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall"; | |
$DesignerVersions = @(); | |
foreach($obj in $InstalledSoftware){ | |
$name = $obj.GetValue('DisplayName'); | |
if($name -like "Q-Sys Designer *") { | |
$designerVersion = ($obj.GetValue('DisplayName') | Select-String -Pattern "(\d+\.\d+)$").Matches.Groups[1].Value; | |
$DesignerVersions += (New-Object PSObject -Property @{ Version = $designerVersion; Path = $obj.GetValue('InstallLocation') }); | |
} | |
} | |
# Find best version | |
$BestVersion = $DesignerVersions | Where-Object {$_.Version -eq $version}; | |
if(($BestVersion | Measure-Object).Count -eq 0) { | |
$BestVersion = ($DesignerVersions | Sort-Object -Property Version | Where-Object {$_.Version -gt $version})[0]; | |
} | |
# Execute designer | |
$exes = Get-ChildItem -Path $BestVersion.Path -Filter "*Designer.exe"; | |
& $exes.FullName $args[0]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment