Rustdesk Silent Installer
# Set error handling
$ErrorActionPreference = 'Stop'
# Generate random password
$rustdesk_pw = -join ((65..90) + (97..122) + (48..57) | Get-Random -Count 12 | % {[char]$_})
# Check admin rights
if (-Not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
Start-Process PowerShell -Verb RunAs "-NoProfile -ExecutionPolicy Bypass -Command `"cd '$pwd'; & '$PSCommandPath'`""
Exit
}
# Check if already installed
$installDir = "$env:ProgramFiles\RustDesk"
if (Test-Path "$installDir\rustdesk.exe") {
Write-Output "✅ RustDesk already installed"
# exit 0 # Uncomment to skip reinstallation
}
# Temp directory setup
if (!(Test-Path C:\Temp)) { New-Item -Path C:\Temp -ItemType Directory -Force | Out-Null }
Set-Location C:\Temp
# Download (if needed)
if (!(Test-Path .\rustdesk.exe)) {
Write-Output "⬇️ Downloading RustDesk..."
Invoke-WebRequest "https://github.com/rustdesk/rustdesk/releases/download/1.2.3-2/rustdesk-1.2.3-2-x86_64.exe" -OutFile rustdesk.exe -UseBasicParsing
}
# Installation with timeout
Write-Output "🛠 Installing RustDesk (max 30 seconds)..."
$installJob = Start-Job -ScriptBlock {
Start-Process $args[0] -ArgumentList "--silent-install" -Wait -NoNewWindow
}