59 lines
2.0 KiB
PowerShell
59 lines
2.0 KiB
PowerShell
#Requires -RunAsAdministrator
|
|
<#
|
|
.SYNOPSIS
|
|
RustDesk Silent Uninstall
|
|
#>
|
|
|
|
$LogFile = "$env:ProgramData\Microsoft\IntuneManagementExtension\Logs\Uninstall-RustDesk.log"
|
|
function Write-Log {
|
|
param([string]$Message)
|
|
$ts = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
|
|
"$ts $Message" | Tee-Object -FilePath $LogFile -Append | Write-Output
|
|
}
|
|
|
|
Write-Log "=== RustDesk Uninstall gestartet ==="
|
|
|
|
# Dienst stoppen
|
|
Stop-Service -Name "RustDesk" -Force -ErrorAction SilentlyContinue
|
|
Stop-Process -Name "rustdesk" -Force -ErrorAction SilentlyContinue
|
|
Start-Sleep -Seconds 2
|
|
|
|
# Über rustdesk.exe deinstallieren
|
|
$RustDeskExe = "$env:ProgramFiles\RustDesk\rustdesk.exe"
|
|
if (Test-Path $RustDeskExe) {
|
|
Write-Log "Starte Uninstall via rustdesk.exe..."
|
|
Start-Process -FilePath $RustDeskExe -ArgumentList "--uninstall-service" -Wait -NoNewWindow -ErrorAction SilentlyContinue
|
|
Start-Process -FilePath $RustDeskExe -ArgumentList "--silent-install", "/uninstall" -Wait -NoNewWindow -ErrorAction SilentlyContinue
|
|
}
|
|
|
|
# Über Registry (Uninstall-String)
|
|
$uninstallKeys = @(
|
|
"HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall",
|
|
"HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall"
|
|
)
|
|
foreach ($key in $uninstallKeys) {
|
|
Get-ChildItem $key -ErrorAction SilentlyContinue | ForEach-Object {
|
|
$displayName = (Get-ItemProperty $_.PSPath -ErrorAction SilentlyContinue).DisplayName
|
|
if ($displayName -like "*RustDesk*") {
|
|
$uninstallStr = (Get-ItemProperty $_.PSPath).UninstallString
|
|
Write-Log "Uninstall-String gefunden: $uninstallStr"
|
|
Start-Process -FilePath "cmd.exe" -ArgumentList "/c $uninstallStr /S" -Wait -NoNewWindow -ErrorAction SilentlyContinue
|
|
}
|
|
}
|
|
}
|
|
|
|
# Reste entfernen
|
|
$paths = @(
|
|
"$env:ProgramFiles\RustDesk",
|
|
"$env:ProgramData\RustDesk"
|
|
)
|
|
foreach ($p in $paths) {
|
|
if (Test-Path $p) {
|
|
Remove-Item -Path $p -Recurse -Force -ErrorAction SilentlyContinue
|
|
Write-Log "Entfernt: $p"
|
|
}
|
|
}
|
|
|
|
Write-Log "=== RustDesk Uninstall abgeschlossen ==="
|
|
exit 0
|