# Installs the newest Termilly for you, on 64-bit Windows 10 or 11: # # irm https://termilly.com/install.ps1 | iex # # It reads https://termilly.com/downloads/latest.json, downloads the online installer named there, checks its # SHA-256 against that file and runs it with --quiet. The installer fetches .NET and WebView2 from Microsoft when # they're missing. It's short on purpose, so you can read it before you run it. $env:TERMILLY_SITE points it at # another server, for testing. # One script block: "irm | iex" runs nothing until the whole script is here, and a failure ends the block, not # your PowerShell window (exit would close it). $code = & { $ErrorActionPreference = 'Stop' $ProgressPreference = 'SilentlyContinue' # Windows PowerShell's progress bar makes downloads many times slower [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12 $site = if ($env:TERMILLY_SITE) { $env:TERMILLY_SITE } else { 'https://termilly.com' } $dir = Join-Path ([IO.Path]::GetTempPath()) ('termilly-install-' + [Guid]::NewGuid().ToString('N')) try { if (-not [Environment]::Is64BitOperatingSystem) { throw 'Termilly needs 64-bit Windows 10 or 11.' } try { $manifest = Invoke-RestMethod -UseBasicParsing "$site/downloads/latest.json" } catch { throw "Couldn't read $site/downloads/latest.json: $($_.Exception.Message)" } $version = $manifest.version $url = $manifest.windows.online $sum = $manifest.windows.sha256 if (-not $version -or -not $url -or -not $sum) { throw "$site/downloads/latest.json doesn't name a Windows installer." } if (-not $env:TERMILLY_SITE -and -not $url.StartsWith('https://')) { throw "The installer's address isn't HTTPS: $url" } New-Item -ItemType Directory $dir | Out-Null $exe = Join-Path $dir 'TermillySetup-online.exe' Write-Host "Downloading Termilly $version" try { Invoke-WebRequest -UseBasicParsing $url -OutFile $exe } catch { throw "Couldn't download ${url}: $($_.Exception.Message)" } if ((Get-FileHash -Algorithm SHA256 $exe).Hash -ne $sum) { throw "The download doesn't match the SHA-256 in latest.json, so it wasn't installed. Try again later." } Write-Host 'Installing it' $setup = [Diagnostics.Process]::Start($exe, '--quiet') $setup.WaitForExit() switch ($setup.ExitCode) { 0 { Write-Host "Termilly $version is installed. Start it from the Start menu, or type termilly in a new terminal." } 740 { Write-Host 'termilly install: setup needs to run as administrator.' -ForegroundColor Red } default { Write-Host "termilly install: setup failed (exit code $_). Its log is in $env:TEMP\TermillySetup-*\setup.log" -ForegroundColor Red } } $setup.ExitCode } catch { Write-Host "termilly install: $($_.Exception.Message)" -ForegroundColor Red 1 } finally { Remove-Item -Recurse -Force -ErrorAction SilentlyContinue $dir } } # Setup's exit code, for scripts (and install.cmd) to check. No exit: under "irm | iex" it would close the caller. $global:LASTEXITCODE = $code