fix(windows): register the notification shortcut identity

This commit is contained in:
Kevin Yue committed 2026-11-18 18:18:07 +08:00
1 parent 8b0d1af648
commit afd5ec3f09
3 files changed
+64 -1

No files matched your search

+6 -1
View File
@@ -24,6 +24,12 @@ $service = Get-CimInstance Win32_Service -Filter "Name='GPConnect'"
if ($service.State -ne 'Running' -or $service.StartMode -ne 'Auto' -or $service.StartName -ne 'LocalSystem') {
throw 'The service did not start automatically as LocalSystem.'
}
$shortcut = Join-Path $env:ProgramData 'Microsoft\Windows\Start Menu\Programs\GP Connect.lnk'
$shell = New-Object -ComObject Shell.Application
$link = $shell.Namespace((Split-Path $shortcut)).ParseName((Split-Path $shortcut -Leaf))
if (!$link -or $link.ExtendedProperty('System.AppUserModel.ID') -ne 'com.yuezk.gpgui') {
throw 'The Start menu shortcut does not register the notification application identity.'
}
foreach ($name in @('gpgui.exe', 'gpauth.exe')) {
$process = Start-Process (Join-Path $destination $name) -ArgumentList '--version' -PassThru -Wait
if ($process.ExitCode -ne 0) { throw "The installed $name cannot start." }
@@ -44,7 +50,6 @@ if ($process.ExitCode -ne 0) { throw 'The uninstaller failed.' }
if ((Get-Service GPConnect -ErrorAction SilentlyContinue) -or (Test-Path $destination) -or (Test-Path ($destination + '.previous'))) {
throw 'The uninstaller left service registration or runtime files.'
}
$shortcut = Join-Path $env:ProgramData 'Microsoft\Windows\Start Menu\Programs\GP Connect.lnk'
if ((Test-Path $shortcut) -or (Test-Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\GPConnect')) {
throw 'The uninstaller left its shortcut or registration.'
}