# Houdini Agent command-line installer (Windows x64) # irm https://houdini-agent.com/install.ps1 | iex # Installs to %LOCALAPPDATA%\Programs\hagent and adds it to your user PATH. # Options (env): HAGENT_INSTALL_DIR, HAGENT_DOWNLOAD_BASE # Runs in its own scope so nothing leaks into the calling session. & { $ErrorActionPreference = "Stop" $ProgressPreference = "SilentlyContinue" # Invoke-WebRequest is very slow with the progress bar on PS 5.1 [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12 $base = if ($env:HAGENT_DOWNLOAD_BASE) { $env:HAGENT_DOWNLOAD_BASE } else { "https://houdini-agent.com/download" } $pkg = "HoudiniAgent-CLI-win64.zip" $dest = if ($env:HAGENT_INSTALL_DIR) { $env:HAGENT_INSTALL_DIR } else { Join-Path $env:LOCALAPPDATA "Programs\hagent" } if (-not [Environment]::Is64BitOperatingSystem) { throw "hagent needs 64-bit Windows." } $tmp = Join-Path ([IO.Path]::GetTempPath()) ("hagent-install-" + [Guid]::NewGuid().ToString("N")) New-Item -ItemType Directory -Path $tmp | Out-Null try { $zip = Join-Path $tmp $pkg Write-Host "Downloading $pkg ..." Invoke-WebRequest -UseBasicParsing -Uri "$base/$pkg" -OutFile $zip $want = $null try { Invoke-WebRequest -UseBasicParsing -Uri "$base/$pkg.sha256" -OutFile "$zip.sha256" $line = (Get-Content -Raw "$zip.sha256").Trim() if ($line -match '^[0-9a-fA-F]{64}') { $want = $Matches[0] } } catch { } if ($want) { $got = (Get-FileHash -Algorithm SHA256 $zip).Hash if ($got -ne $want.ToUpper()) { throw "Checksum mismatch (expected $want, got $got)." } Write-Host "Checksum OK." } # A running hagent.exe locks its files Get-Process hagent -ErrorAction SilentlyContinue | Where-Object { $_.Path -and $_.Path.StartsWith($dest, [StringComparison]::OrdinalIgnoreCase) } | ForEach-Object { throw "hagent is running ($($_.Path)). Close it and run the installer again." } Write-Host "Installing to $dest ..." Expand-Archive -Path $zip -DestinationPath (Join-Path $tmp "x") -Force $src = Join-Path $tmp "x\hagent" if (-not (Test-Path (Join-Path $src "hagent.exe"))) { throw "Unexpected package layout." } if (Test-Path $dest) { Remove-Item -Recurse -Force $dest } New-Item -ItemType Directory -Path (Split-Path $dest) -Force | Out-Null Move-Item $src $dest $userPath = [Environment]::GetEnvironmentVariable("Path", "User") $parts = @($userPath -split ";" | Where-Object { $_ }) if (-not ($parts | Where-Object { $_.TrimEnd("\") -ieq $dest.TrimEnd("\") })) { [Environment]::SetEnvironmentVariable("Path", (($parts + $dest) -join ";"), "User") Write-Host "Added $dest to your user PATH." } if (-not (($env:Path -split ";") | Where-Object { $_.TrimEnd("\") -ieq $dest.TrimEnd("\") })) { $env:Path += ";$dest" } Write-Host "" Write-Host ("Installed: " + (& (Join-Path $dest "hagent.exe") --version)) Write-Host "Run: hagent (open a new terminal if the command is not found)" Write-Host "Uninstall: delete $dest and remove it from your user PATH." } finally { Remove-Item -Recurse -Force $tmp -ErrorAction SilentlyContinue } }