$Destination = [Environment]::GetFolderPath("UserProfile") + "\Downloads"
$ExtractFolder = Join-Path $Destination "Devolutions.RemoteDesktopManager.Portable"
$7zip = "C:\Program Files\7-Zip\7z.exe"
$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."
}
$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"