# 1. Define known AnyDesk service wildcard strings $ServicePatterns = @("*AnyDesk*") Write-Host "=== ANYDESK ALL-INSTANCE RESTORATION SCRIPT ===" -ForegroundColor Cyan # 2. Enumerate, enable, and start matching background system services Write-Host "`n[+] Scanning and restoring services..." -ForegroundColor White foreach ($Pattern in $ServicePatterns) { $Services = Get-Service -Name $Pattern -ErrorAction SilentlyContinue if ($Services) { foreach ($Service in $Services) { Write-Host " -> Found Service: $($Service.Name) [Current Status: $($Service.Status)]" -ForegroundColor Yellow # Change startup back to Automatic so it runs normally on reboot Set-Service -Name $Service.Name -StartupType Automatic -Confirm:$false -ErrorAction SilentlyContinue Write-Host " [✓] Startup type restored to Automatic." -ForegroundColor Green # Start the service back up Start-Service -Name $Service.Name -ErrorAction SilentlyContinue Write-Host " [✓] Service commanded to Start." -ForegroundColor Green } } else { Write-Host "No services matching '$Pattern' found to restore." -ForegroundColor Gray } } # 3. Final verification output Write-Host "`n=== POST-RESTORATION CHECK ===" -ForegroundColor Cyan $FinalServices = Get-Service -Name $ServicePatterns -ErrorAction SilentlyContinue if ($FinalServices) { Write-Host "[+] Current status of restored services:" -ForegroundColor White $FinalServices | Select-Object Name, Status, StartType | Format-Table -AutoSize } else { Write-Host "[!] No AnyDesk services were found on this system." -ForegroundColor Red } Write-Host "Script execution completed." -ForegroundColor Green # Define all AnyDesk executable files used in the previous steps $executables = @( "AnyDesk.exe", "AnyDesk_update.exe" ) # Base path for Image File Execution Options $basePath = "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options" # Loop through each executable name and completely delete its IFEO block key foreach ($exe in $executables) { $targetPath = Join-Path $basePath $exe # Check if the registry key exists before attempting deletion if (Test-Path $targetPath) { Remove-Item -Path $targetPath -Force -Recurse Write-Host "[Restored] Removed all blocks and payloads for: $exe" -ForegroundColor Green } else { Write-Host "[Clean] No registry block found for: $exe" -ForegroundColor Gray } } Write-Host "`nAll AnyDesk registry blocks have been successfully removed." -ForegroundColor Green