# Minerva installer for Windows. # # irm https://aboutminerva.com/install.ps1 | iex # # Installs the latest release named by the per-platform manifest the app's own # auto-updater reads, so the script never changes per release. The installer # is per-user (%LOCALAPPDATA%\Minerva), so there's no admin prompt, and a file # PowerShell downloads carries no mark-of-the-web, so SmartScreen doesn't stop # the unsigned installer either. # # Optional environment: # MINERVA_UPDATES_URL release host (default: https://updates.aboutminerva.com) # # macOS and Linux: curl -fsSL https://aboutminerva.com/install.sh | sh # # Runs in its own script block so nothing leaks into the caller's session. # Errors are thrown, never exit-ed: under iex, exit would close the window. # Keep this file ASCII: Windows PowerShell can decode anything else wrongly. & { $ErrorActionPreference = 'Stop' # Windows PowerShell redraws its progress bar so often that downloads crawl. $ProgressPreference = 'SilentlyContinue' if ($env:OS -ne 'Windows_NT') { throw 'This installer is for Windows. On macOS or Linux, run: curl -fsSL https://aboutminerva.com/install.sh | sh' } # 32-bit PowerShell on 64-bit Windows reports x86 and keeps the real # architecture in PROCESSOR_ARCHITEW6432. Windows on Arm runs the x64 build. $arch = if ($env:PROCESSOR_ARCHITEW6432) { $env:PROCESSOR_ARCHITEW6432 } else { $env:PROCESSOR_ARCHITECTURE } if ($arch -ne 'AMD64' -and $arch -ne 'ARM64') { throw "Minerva needs 64-bit Windows; this PC reports $arch." } # The silent installer would kill a running Minerva, losing the windows it # saves for next launch when it quits normally. Closing the window only # hides it to the tray, so ask for a real quit instead. if (Get-Process -Name 'research-platform' -ErrorAction SilentlyContinue) { throw 'Minerva is running. Quit it (right-click its tray icon, then Quit) and run this again.' } # Windows PowerShell 5.1 can still default to TLS 1.0. [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12 $base = 'https://updates.aboutminerva.com' if ($env:MINERVA_UPDATES_URL) { $base = $env:MINERVA_UPDATES_URL.TrimEnd('/') } $target = 'windows-x86_64' $manifestUrl = "$base/updates/app/$target/latest.json" try { $manifest = Invoke-RestMethod -Uri $manifestUrl -UseBasicParsing } catch { throw "Couldn't fetch the latest release from ${manifestUrl}: $($_.Exception.Message)" } $version = $manifest.version $url = $manifest.platforms.$target.url if (-not $version -or $url -notlike '*.exe') { throw "Unexpected release manifest at $manifestUrl." } $installed = Get-ItemProperty -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall\Minerva' -ErrorAction SilentlyContinue $current = if ($installed) { $installed.DisplayVersion } if (-not $current) { Write-Host "Installing Minerva $version" } elseif ($current -eq $version) { Write-Host "Reinstalling Minerva $version" } else { Write-Host "Updating Minerva $current to $version" } $installer = Join-Path ([IO.Path]::GetTempPath()) ([IO.Path]::GetFileName(([Uri]$url).LocalPath)) try { Write-Host "Downloading $url" Invoke-WebRequest -Uri $url -OutFile $installer -UseBasicParsing Write-Host 'Running the installer' # WaitForExit rather than Start-Process -Wait, which in Windows # PowerShell also waits on anything the installer leaves running. $process = Start-Process -FilePath $installer -ArgumentList '/S' -PassThru $null = $process.Handle # hold a handle so ExitCode survives the exit $process.WaitForExit() if ($process.ExitCode -ne 0) { throw "The installer failed (exit code $($process.ExitCode))." } } finally { Remove-Item -LiteralPath $installer -Force -ErrorAction SilentlyContinue } Write-Host "Minerva $version is installed. Open it from the Start menu." }