Explicitly uninstall existing version before install to avoid MSI upgrade elevation failure

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
uhlwoogi
2026-04-15 10:58:30 +00:00
co-authored by Claude Sonnet 4.6
parent 640567d03e
commit eb0d4aaaf9
2 changed files with 41 additions and 5 deletions
@@ -26,6 +26,27 @@ $rustdeskService = 'ScoutIT-RemoteSupport'
function Install-RustDesk {
$msiPath = "$env:SystemRoot\Temp\$rustdeskMsi"
# Uninstall any existing version first (prevents MSI upgrade elevation failure)
$uninstallKeys = @(
'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*',
'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*'
)
foreach ($key in $uninstallKeys) {
Get-ItemProperty $key -ErrorAction SilentlyContinue |
Where-Object { $_.DisplayName -match 'ScoutIT-RemoteSupport|ScoutIT RemoteSupport|rustdesk' -or
$_.Publisher -match 'scoutit|rustdesk' } |
ForEach-Object {
$productCode = $_.PSChildName
Write-Host "Found existing install: $($_.DisplayName) [$productCode] - uninstalling..."
Stop-Service -Name $rustdeskService -Force -ErrorAction SilentlyContinue
Start-Process -FilePath "msiexec.exe" `
-ArgumentList "/x `"$productCode`" /qn /norestart" `
-Wait
Start-Sleep -Seconds 10
Write-Host "Existing version removed."
}
}
# Download
Write-Host "Downloading ScoutIT Remote Support client..."
Try {