# Installs the infinitodo agent runner on this Windows computer. In PowerShell: # # irm https://infinitodo.com/downloads/agent-runner/install.ps1 | iex # # It downloads the single-file app (checking its SHA-256) into # %LOCALAPPDATA%\Programs\infinitodo-agent, sets it to start when you log in # (with an icon by the clock), and opens its setup page. No administrator # needed. Run it again to update. # # $env:INFINITODO_DOWNLOADS where to download from (default below) $ErrorActionPreference = "Stop" $ProgressPreference = "SilentlyContinue" # much faster downloads $base = if ($env:INFINITODO_DOWNLOADS) { $env:INFINITODO_DOWNLOADS } else { "https://infinitodo.com/downloads/agent-runner" } $dir = Join-Path $env:LOCALAPPDATA "Programs\infinitodo-agent" $file = "infinitodo-agent-windows-x64.exe" $app = Join-Path $dir "infinitodo-agent.exe" $tmp = Join-Path ([System.IO.Path]::GetTempPath()) ("infinitodo-" + [guid]::NewGuid()) New-Item -ItemType Directory -Force -Path $tmp | Out-Null try { Write-Host "Downloading the infinitodo agent runner (Windows)..." Invoke-WebRequest -UseBasicParsing "$base/$file" -OutFile (Join-Path $tmp $file) Invoke-WebRequest -UseBasicParsing "$base/SHA256SUMS" -OutFile (Join-Path $tmp "SHA256SUMS") $expected = (Get-Content (Join-Path $tmp "SHA256SUMS") | Where-Object { $_ -match "\s$([regex]::Escape($file))$" } | ForEach-Object { ($_ -split "\s+")[0] }) $actual = (Get-FileHash -Algorithm SHA256 (Join-Path $tmp $file)).Hash.ToLower() if (-not $expected -or $expected -ne $actual) { throw "The download didn't check out (SHA-256); try again." } # An update: stop the running one first (Windows won't replace a running app). if (Test-Path $app) { & $app uninstall | Out-Null } Get-Process -Name "infinitodo-agent" -ErrorAction SilentlyContinue | Stop-Process -Force -ErrorAction SilentlyContinue Start-Sleep -Milliseconds 500 New-Item -ItemType Directory -Force -Path $dir | Out-Null Move-Item -Force (Join-Path $tmp $file) $app Write-Host "Installed $app" # So "infinitodo-agent" works in a new terminal. $path = [Environment]::GetEnvironmentVariable("Path", "User") if (-not ($path -split ";" | Where-Object { $_ -eq $dir })) { [Environment]::SetEnvironmentVariable("Path", ((@($path, $dir) | Where-Object { $_ }) -join ";"), "User") } & $app install Write-Host "To remove it later: Uninstall at the bottom of its setup page, or in Settings > Apps > Installed apps." } finally { Remove-Item -Recurse -Force $tmp -ErrorAction SilentlyContinue }