$Destination = [Environment]::GetFolderPath("UserProfile") + "\Downloads"
$ExtractFolder = Join-Path $Destination "Devolutions.RemoteDesktopManager.Portable"
$7zip = "C:\Program Files\7-Zip\7z.exe"
# Close RDM if running
$rdm = Get-Process -Name "RemoteDesktopManager_x64" -ErrorAction SilentlyContinue
if ($rdm) {
Write-Host "Closing RDM..."
$rdm.CloseMainWindow() | Out-Null
$rdm.WaitForExit(10000)
if (!$rdm.HasExited) { $rdm.Kill() }
Write-Host "RDM closed."
}
# Download and extract RDM portable
$info = (Invoke-RestMethod 'https://devolutions.net/products.htm') -split "`n" |
Where-Object { $_ -match '^RDM7zX64\.' } |
ForEach-Object { $k, $v = $_ -split '=', 2; [PSCustomObject]@{ Key = $k.Trim(); Value = $v.Trim() } }
$version = ($info | Where-Object Key -eq 'RDM7zX64.Version').Value
$url = ($info | Where-Object Key -eq 'RDM7zX64.Url').Value
$outFile = Join-Path $Destination ([System.IO.Path]::GetFileName($url))
New-Item -ItemType Directory -Path $Destination -Force | Out-Null
Write-Host "Downloading RDM $version portable..."
(New-Object System.Net.WebClient).DownloadFile($url, $outFile)
Write-Host "Downloaded: $outFile"
Write-Host "Extracting to: $ExtractFolder"
& $7zip x $outFile -o"$ExtractFolder" -aoa -y
Write-Host "Done. RDM $version portable is ready in: $ExtractFolder"
# Check and install .NET Desktop Runtime 10
Write-Host ""
Write-Host "Checking .NET Desktop Runtime 10..."
$releasesIndex = Invoke-RestMethod 'https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/releases-index.json'
$latestVersion = ($releasesIndex.'releases-index' | Where-Object { $_.'channel-version' -eq '10.0' }).'latest-runtime'
$installed = & dotnet --list-runtimes 2>$null |
Where-Object { $_ -match '^Microsoft\.WindowsDesktop\.App 10\.' } |
ForEach-Object { ($_ -split ' ')[1] } |
Sort-Object { [version]$_ } |
Select-Object -Last 1
if ($installed -and [version]$installed -ge [version]$latestVersion) {
Write-Host ".NET Desktop Runtime 10 is up to date ($installed)."
} else {
if ($installed) {
Write-Host "Installed: $installed -- newer version available: $latestVersion"
} else {
Write-Host ".NET Desktop Runtime 10 not found. Installing $latestVersion..."
}
$installerUrl = "https://dotnetcli.blob.core.windows.net/dotnet/WindowsDesktop/$latestVersion/windowsdesktop-runtime-$latestVersion-win-x64.exe"
$installerFile = Join-Path $Destination "windowsdesktop-runtime-$latestVersion-win-x64.exe"
Write-Host "Downloading .NET Desktop Runtime $latestVersion..."
(New-Object System.Net.WebClient).DownloadFile($installerUrl, $installerFile)
Write-Host "Downloaded: $installerFile"
Write-Host "Installing .NET Desktop Runtime $latestVersion..."
$proc = Start-Process -FilePath $installerFile -ArgumentList '/install', '/quiet', '/norestart' -Wait -PassThru
if ($proc.ExitCode -eq 0 -or $proc.ExitCode -eq 3010) {
Write-Host ".NET Desktop Runtime $latestVersion installed successfully."
if ($proc.ExitCode -eq 3010) { Write-Host "A reboot is required to complete the installation." }
} else {
Write-Warning ".NET Desktop Runtime installer exited with code $($proc.ExitCode)."
}
}