# HelpMeTest CLI installer for Windows (PowerShell) # Usage: irm https://helpmetest.com/install.ps1 | iex $ErrorActionPreference = 'Stop' $BaseUrl = 'https://helpmetest.com' $ProgName = 'helpmetest' function Fail($msg) { Write-Host "Error: $msg" -ForegroundColor Red; exit 1 } # Only 64-bit Windows is published. $arch = $env:PROCESSOR_ARCHITECTURE if ($arch -ne 'AMD64' -and $arch -ne 'ARM64') { Fail "unsupported architecture: $arch (only 64-bit Windows is supported)" } Write-Host "Resolving latest release..." try { $release = Invoke-RestMethod -Uri "$BaseUrl/install.json" -UseBasicParsing } catch { Fail "could not reach $BaseUrl/install.json ($($_.Exception.Message))" } $asset = $release.Assets | Where-Object { $_.OS -eq 'windows' -and $_.Type -eq 'zip' } | Select-Object -First 1 if (-not $asset) { Fail "no Windows asset in release $($release.ResolvedRelease)" } Write-Host "Installing $ProgName $($release.ResolvedRelease) (windows/x64)..." $tmp = Join-Path $env:TEMP ("hmt-install-" + [System.Guid]::NewGuid().ToString('N')) New-Item -ItemType Directory -Path $tmp -Force | Out-Null try { $zip = Join-Path $tmp 'helpmetest.zip' Invoke-WebRequest -Uri $asset.URL -OutFile $zip -UseBasicParsing Expand-Archive -Path $zip -DestinationPath $tmp -Force $exe = Get-ChildItem -Path $tmp -Recurse -Filter 'helpmetest.exe' | Select-Object -First 1 if (-not $exe) { Fail "helpmetest.exe not found in downloaded archive" } $installDir = Join-Path $env:LOCALAPPDATA 'Programs\helpmetest' New-Item -ItemType Directory -Path $installDir -Force | Out-Null $dest = Join-Path $installDir 'helpmetest.exe' Copy-Item -Path $exe.FullName -Destination $dest -Force # Add install dir to the user PATH (persisted), and to this session. $userPath = [Environment]::GetEnvironmentVariable('Path', 'User') if (-not $userPath) { $userPath = '' } $onPath = $userPath.Split(';') | Where-Object { $_ -eq $installDir } if (-not $onPath) { $newPath = if ($userPath.TrimEnd(';')) { $userPath.TrimEnd(';') + ';' + $installDir } else { $installDir } [Environment]::SetEnvironmentVariable('Path', $newPath, 'User') Write-Host "Added $installDir to your PATH." } if (-not ($env:Path.Split(';') | Where-Object { $_ -eq $installDir })) { $env:Path = $env:Path.TrimEnd(';') + ';' + $installDir } Write-Host "Installed at $dest" -ForegroundColor Green Write-Host "" Write-Host "Run 'helpmetest --version' to verify. If not found, open a new terminal." } finally { Remove-Item -Path $tmp -Recurse -Force -ErrorAction SilentlyContinue }