# MAE Remote Desktop - one-line installer for Windows 10/11 (64-bit) # # Run in PowerShell: # irm https://remote.maesuaisystem.com/install.ps1 | iex # # For a computer you will access without anyone in front of it, set a permanent password first. # This needs PowerShell opened with "Run as administrator": # $env:MAE_PASSWORD = 'CHANGE-ME'; irm https://remote.maesuaisystem.com/install.ps1 | iex # # Only run this on your own computers or computers you look after. Never run it because someone # on the phone told you to. & { $ErrorActionPreference = 'Stop' $ProgressPreference = 'SilentlyContinue' [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 $Site = 'https://remote.maesuaisystem.com' $App = 'MAERemote' function Say([string]$Text, [string]$Color = 'Gray') { Write-Host $Text -ForegroundColor $Color } if (-not [Environment]::Is64BitOperatingSystem) { Say 'MAE Remote needs 64-bit Windows 10 or 11.' Red; return } $isAdmin = ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole( [Security.Principal.WindowsBuiltInRole]::Administrator) if ($env:MAE_PASSWORD -and ($env:MAE_PASSWORD -eq 'CHANGE-ME' -or $env:MAE_PASSWORD.Length -lt 8)) { Say 'Replace CHANGE-ME with your own password (at least 8 characters) and run the command again.' Yellow return } if (-not $isAdmin) { if ($env:MAE_PASSWORD) { Say 'Setting a permanent password needs administrator rights.' Yellow Say 'Open PowerShell with "Run as administrator" and run the command again.' Yellow return } Say 'Administrator rights are needed. Click "Yes" in the window that opens.' Yellow Start-Process powershell.exe -Verb RunAs -ArgumentList @( '-NoProfile', '-ExecutionPolicy', 'Bypass', '-NoExit', '-Command', "irm $Site/install.ps1 | iex") return } $latest = Invoke-RestMethod "$Site/version.json" $name = "MAERemote-$($latest.version)-x86_64.exe" $work = Join-Path $env:TEMP ("mae-install-" + [guid]::NewGuid().ToString('N')) New-Item -ItemType Directory -Path $work | Out-Null try { $setup = Join-Path $work $name Say "Downloading MAE Remote $($latest.version) ..." Cyan Invoke-WebRequest "$Site/download/$name" -OutFile $setup -UseBasicParsing Invoke-WebRequest "$Site/download/SHA256SUMS" -OutFile (Join-Path $work 'SHA256SUMS') -UseBasicParsing $want = Get-Content (Join-Path $work 'SHA256SUMS') | Where-Object { $_ -match [regex]::Escape($name) } | ForEach-Object { ($_ -split '\s+')[0].ToLower() } | Select-Object -First 1 $got = (Get-FileHash $setup -Algorithm SHA256).Hash.ToLower() if (-not $want -or $got -ne $want) { Say "The download does not match its SHA-256 checksum. Nothing was installed." Red; return } Say 'Checksum OK. Installing ...' Cyan # The setup file unpacks itself and starts the real installer, then exits; wait for that installer # (not with -Wait: it would also wait for the app the installer leaves running). (Start-Process -FilePath $setup -ArgumentList '--silent-install' -PassThru).WaitForExit() Start-Sleep -Seconds 2 for ($i = 0; $i -lt 180; $i++) { $busy = Get-CimInstance Win32_Process -Filter "CommandLine LIKE '%--silent-install%'" -ErrorAction SilentlyContinue if (-not $busy) { break } Start-Sleep -Seconds 1 } $exe = Join-Path $env:ProgramFiles "$App\$App.exe" $ready = $false for ($i = 0; $i -lt 60; $i++) { $svc = Get-Service -Name $App -ErrorAction SilentlyContinue if ((Test-Path $exe) -and $svc -and $svc.Status -eq 'Running') { $ready = $true; break } Start-Sleep -Seconds 1 } if (-not $ready) { Say "The installation did not finish. Download the setup file from $Site and run it." Red; return } if ($env:MAE_PASSWORD) { Start-Sleep -Seconds 3 $res = (& $exe --password $env:MAE_PASSWORD | Out-String).Trim() if ($res -match 'Done') { Say 'Permanent password set.' Green } else { Say "Could not set the password: $res" Yellow } } $id = '' for ($i = 0; $i -lt 20 -and -not $id; $i++) { $id = (& $exe --get-id | Out-String).Trim() if (-not $id) { Start-Sleep -Seconds 2 } } if ($id -match '^\d{9}$') { $id = $id.Substring(0, 3) + ' ' + $id.Substring(3, 3) + ' ' + $id.Substring(6) } Say '' Say ' MAE Remote Desktop is installed.' Green if ($id) { Say " This computer's address: $id" White } Say ' Open it from the Start menu or the desktop icon.' Say '' } finally { Remove-Item -Recurse -Force $work -ErrorAction SilentlyContinue } }