feat: detect and uninstall old RustDesk before install

This commit is contained in:
Windneiro 2026-04-14 11:29:37 +05:00
parent e020cb0aed
commit 50cb323ff6
1 changed files with 36 additions and 0 deletions

View File

@ -86,6 +86,42 @@ Write-Host " Downloading..." -ForegroundColor Gray
Invoke-WebRequest -Uri $rdUrl -OutFile $rdPath -ErrorAction Stop Invoke-WebRequest -Uri $rdUrl -OutFile $rdPath -ErrorAction Stop
Write-Host " Downloaded" -ForegroundColor Green Write-Host " Downloaded" -ForegroundColor Green
# Proveryaem est li uzhe ustanovlennyj RustDesk i udalyaem
$oldUninstallPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\rustdesk"
$oldVersion = $null
if (Test-Path $oldUninstallPath) {
$oldVersion = (Get-ItemProperty $oldUninstallPath).DisplayVersion
}
if ($oldVersion) {
Write-Host " Old version detected: $oldVersion" -ForegroundColor Yellow
Write-Host " Removing old version..." -ForegroundColor Gray
# Probuem cherez UninstallString
$uninstallStr = (Get-ItemProperty $oldUninstallPath).UninstallString
if ($uninstallStr) {
if ($uninstallStr -match '"(.+)"') {
$uninstallExe = $matches[1]
$uninstallArgs = '/S'
if ($uninstallStr -match '"(.+)"\s+(.+)') {
$uninstallExe = $matches[1]
$uninstallArgs = $matches[2]
}
Start-Process $uninstallExe -ArgumentList $uninstallArgs -Wait -NoNewWindow -ErrorAction SilentlyContinue
Start-Sleep -Seconds 3
}
}
# Takzhe cherez WMI
$oldApp = Get-WmiObject -Class Win32_Product -Filter "Name='RustDesk'" -ErrorAction SilentlyContinue
if ($oldApp) {
$oldApp.Uninstall() | Out-Null
Start-Sleep -Seconds 3
}
Write-Host " Old version removed" -ForegroundColor Green
}
Write-Host " Installing..." -ForegroundColor Gray Write-Host " Installing..." -ForegroundColor Gray
$result = Start-Process $rdPath -ArgumentList "/VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP-" -Wait -PassThru -NoNewWindow $result = Start-Process $rdPath -ArgumentList "/VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP-" -Wait -PassThru -NoNewWindow