Added App Icon

This commit is contained in:
2026-08-28 17:40:43 +02:00
parent 73c20a0ff2
commit 7c85397af0
16 changed files with 178 additions and 2 deletions
+43
View File
@@ -0,0 +1,43 @@
param([switch]$UpdateIcon)
$ErrorActionPreference = 'Stop'
$shortcutProject = $PSScriptRoot
$shortcutMarker = Join-Path $shortcutProject 'runtime\desktop-shortcut-created.txt'
if ((Test-Path -LiteralPath $shortcutMarker) -and -not $UpdateIcon) { return }
try {
# Resolves the real Desktop, including a redirected/OneDrive Desktop.
$shortcutDesktop = [Environment]::GetFolderPath('DesktopDirectory')
if (-not $shortcutDesktop) { throw 'Windows Desktop folder is unavailable.' }
$shortcutPath = Join-Path $shortcutDesktop 'SUB Control.lnk'
# Never replace a shortcut the user already has.
if (-not (Test-Path -LiteralPath $shortcutPath)) {
$shortcutShell = New-Object -ComObject WScript.Shell
$shortcutLink = $shortcutShell.CreateShortcut($shortcutPath)
$shortcutLink.TargetPath = Join-Path $env:SystemRoot 'System32\WindowsPowerShell\v1.0\powershell.exe'
$shortcutLink.Arguments = '-NoProfile -WindowStyle Hidden -File "' + (Join-Path $shortcutProject 'run.ps1') + '"'
$shortcutLink.WorkingDirectory = $shortcutProject
$shortcutLink.Description = 'Launch SUB Control'
$shortcutLink.WindowStyle = 7
$shortcutIcon = Join-Path $shortcutProject 'assets\sub-control.ico'
if (Test-Path -LiteralPath $shortcutIcon) { $shortcutLink.IconLocation = "$shortcutIcon,0" }
$shortcutLink.Save()
} elseif ($UpdateIcon) {
$shortcutShell = New-Object -ComObject WScript.Shell
$shortcutLink = $shortcutShell.CreateShortcut($shortcutPath)
$expectedScript = '"' + (Join-Path $shortcutProject 'run.ps1') + '"'
if ($shortcutLink.Arguments.Contains($expectedScript)) {
$shortcutLink.IconLocation = (Join-Path $shortcutProject 'assets\sub-control.ico') + ',0'
$shortcutLink.Save()
} else {
throw 'Existing shortcut belongs to another installation; left unchanged.'
}
}
New-Item -ItemType Directory -Path (Split-Path -Parent $shortcutMarker) -Force | Out-Null
Set-Content -LiteralPath $shortcutMarker -Value $shortcutPath
} catch {
# Desktop permissions must not prevent the controller from starting.
Write-Warning "Could not create the SUB Control desktop shortcut: $_"
}