Skip to content

Instantly share code, notes, and snippets.

@gdyr
Created February 3, 2021 01:30
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gdyr/3e3731cc55ccd55d972c9b8eb0823283 to your computer and use it in GitHub Desktop.
Save gdyr/3e3731cc55ccd55d972c9b8eb0823283 to your computer and use it in GitHub Desktop.
Automatically launch best Q-Sys Designer version for design file
# 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