# Installs ot on Windows. # # irm https://otinstaller.com/install.ps1 | iex # # Environment: # OT_VERSION version to install, without a leading v (default: latest) # OT_INSTALL_DIR where to put ot.exe (default: %LOCALAPPDATA%\Programs\ot) # OT_NO_MODIFY_PATH set to 1 to leave your PATH alone $ErrorActionPreference = 'Stop' $ProgressPreference = 'SilentlyContinue' $base = if ($env:OT_INSTALL_BASE_URL) { $env:OT_INSTALL_BASE_URL } else { 'https://otinstaller.com/releases' } $dir = if ($env:OT_INSTALL_DIR) { $env:OT_INSTALL_DIR } else { Join-Path $env:LOCALAPPDATA 'Programs\ot' } $version = if ($env:OT_VERSION) { $env:OT_VERSION } else { 'latest' } $arch = switch ($env:PROCESSOR_ARCHITECTURE) { 'AMD64' { 'amd64' } 'ARM64' { 'arm64' } default { throw "Unsupported CPU: $env:PROCESSOR_ARCHITECTURE" } } if ($version -eq 'latest') { $version = (Invoke-WebRequest -Uri "$base/latest.txt" -UseBasicParsing).Content.Trim() if ($version -notmatch '^[0-9A-Za-z.-]+$') { throw "$base/latest.txt does not hold a version" } } $archive = "ot_${version}_windows_${arch}.zip" $url = "$base/v$version" $tmp = Join-Path ([System.IO.Path]::GetTempPath()) ("ot-install-" + [System.Guid]::NewGuid().ToString('N')) New-Item -ItemType Directory -Path $tmp | Out-Null try { Write-Host "Downloading ot $version for windows/$arch" Invoke-WebRequest -Uri "$url/$archive" -OutFile (Join-Path $tmp $archive) -UseBasicParsing Invoke-WebRequest -Uri "$url/checksums.txt" -OutFile (Join-Path $tmp 'checksums.txt') -UseBasicParsing $want = $null foreach ($line in Get-Content (Join-Path $tmp 'checksums.txt')) { $parts = $line -split '\s+' if ($parts.Count -ge 2 -and $parts[1] -eq $archive) { $want = $parts[0] } } if (-not $want) { throw "checksums.txt has no entry for $archive" } $got = (Get-FileHash -Algorithm SHA256 (Join-Path $tmp $archive)).Hash if ($got -ne $want) { throw "Checksum mismatch for ${archive}: expected $want, got $got" } Expand-Archive -Path (Join-Path $tmp $archive) -DestinationPath (Join-Path $tmp 'out') New-Item -ItemType Directory -Force -Path $dir | Out-Null Copy-Item -Force (Join-Path $tmp 'out\ot.exe') (Join-Path $dir 'ot.exe') } finally { Remove-Item -Recurse -Force $tmp -ErrorAction SilentlyContinue } Write-Host "Installed $(Join-Path $dir 'ot.exe')" $userPath = [Environment]::GetEnvironmentVariable('Path', 'User') $onPath = ($userPath -split ';') -contains $dir if (-not $onPath -and $env:OT_NO_MODIFY_PATH -ne '1') { [Environment]::SetEnvironmentVariable('Path', ($userPath.TrimEnd(';') + ';' + $dir), 'User') Write-Host "Added $dir to your PATH. Open a new terminal to use 'ot'." } elseif (-not $onPath) { Write-Host "Add $dir to your PATH to run it as 'ot'." } Write-Host 'Next: ot list' Write-Host 'Note: ot mcp reports anonymous usage counts, never targets. "ot telemetry off" stops it: https://otinstaller.com/privacy/'