$enteredPassword = Read-Host -Prompt "Enter deployment password" if ($enteredPassword -ne "QwertyFM4024.") { Write-Host "Access denied. Incorrect password." -ForegroundColor Red Start-Sleep -Seconds 3 exit } Write-Host "Starting RustDesk configuration..." -ForegroundColor Cyan $rustdeskAlias = Read-Host -Prompt "Enter the RustDesk display name (Press Enter to use default computer name)" $remotePassword = Read-Host -Prompt "Enter the permanent password for remote access" $apiUrl = "https://api.github.com/repos/rustdesk/rustdesk/releases/latest" $latestRelease = Invoke-RestMethod -Uri $apiUrl $exeAsset = $latestRelease.assets | Where-Object { $_.name -match "x86_64\.exe$" } $downloadUrl = $exeAsset.browser_download_url $targetFileName = "rustdesk-host=rmdsk.innovexitsolutions.com,key=wFZ1ciniHwIMDMfYiGwXd3MtMUyefETWn93tk6ZuZgU=.exe" $installerPath = "$env:TEMP/$targetFileName" Write-Host "Downloading installer..." Invoke-WebRequest -Uri $downloadUrl -OutFile $installerPath Write-Host "Running silent installation..." Start-Process -FilePath $installerPath -ArgumentList "--silent-install" -Wait -NoNewWindow Start-Sleep -Seconds 5 Write-Host "Configuring API server and alias..." Stop-Service -Name "RustDeskService" -Force -ErrorAction SilentlyContinue $configDir = "C:/Windows/ServiceProfiles/LocalService/AppData/Roaming/RustDesk/config" if (-not (Test-Path $configDir)) { New-Item -Path $configDir -ItemType Directory -Force | Out-Null } $configFile = "$configDir/RustDesk2.toml" $tomlContent = "api-server = 'https://rdeskapi.innovexitsolutions.com'`n" if (-not [string]::IsNullOrWhiteSpace($rustdeskAlias)) { $tomlContent += "custom-alias = '$rustdeskAlias'`n" } [System.IO.File]::WriteAllText($configFile, $tomlContent, [System.Text.Encoding]::UTF8) Start-Service -Name "RustDeskService" Start-Sleep -Seconds 3 # Configure unattended access password $installedExe = "C:/Program Files/RustDesk/rustdesk.exe" if (Test-Path $installedExe) { Write-Host "Configuring access password..." Start-Process -FilePath $installedExe -ArgumentList "--password $remotePassword" -Wait -NoNewWindow } Remove-Item -Path $installerPath -Force -ErrorAction SilentlyContinue Write-Host "Deployment completed successfully! Closing console..." -ForegroundColor Green Start-Sleep -Seconds 3 exit