feat: detect and uninstall old RustDesk before install
This commit is contained in:
parent
e020cb0aed
commit
50cb323ff6
36
rd_setup.ps1
36
rd_setup.ps1
|
|
@ -86,6 +86,42 @@ Write-Host " Downloading..." -ForegroundColor Gray
|
|||
Invoke-WebRequest -Uri $rdUrl -OutFile $rdPath -ErrorAction Stop
|
||||
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
|
||||
$result = Start-Process $rdPath -ArgumentList "/VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP-" -Wait -PassThru -NoNewWindow
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue