# Installs Hobfolk on Windows, from PowerShell: # # irm https://hobfolk.dev/install.ps1 | iex # # It finds the processor, downloads the latest installer from https://hobfolk.dev/download, checks its # SHA-256 against the one the server publishes and runs it silently, for your user only (no admin). # Run it again to update. $env:HOBFOLK_DOWNLOAD_URL points it at another server (a self-hosted one). & { $ErrorActionPreference = 'Stop' $ProgressPreference = 'SilentlyContinue' [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12 $base = if ($env:HOBFOLK_DOWNLOAD_URL) { $env:HOBFOLK_DOWNLOAD_URL.TrimEnd('/') } else { 'https://hobfolk.dev' } $arch = if ($env:PROCESSOR_ARCHITEW6432 -eq 'ARM64' -or $env:PROCESSOR_ARCHITECTURE -eq 'ARM64') { 'arm64' } else { 'x64' } if (-not [Environment]::Is64BitOperatingSystem) { throw 'Hobfolk needs 64-bit Windows.' } # An arm64 installer when there is one; otherwise the x64 one, which Windows on ARM emulates. $target = $null $sum = $null foreach ($candidate in @("win-$arch", 'win-x64') | Select-Object -Unique) { try { $sum = (Invoke-WebRequest -UseBasicParsing -Uri "$base/download/$candidate.sha256").Content if ($sum -is [byte[]]) { $sum = [Text.Encoding]::UTF8.GetString($sum) } $target = $candidate break } catch { $status = $_.Exception.Response.StatusCode.value__ if ($status -ne 404) { throw "Could not reach $base ($($_.Exception.Message)). Check your connection and try again." } } } if (-not $target) { throw "There is no Hobfolk build for Windows at $base yet. See $base/download" } $parts = $sum.Trim() -split '\s+', 2 $expected = $parts[0].ToLowerInvariant() $file = $parts[1] if ($expected -notmatch '^[0-9a-f]{64}$' -or -not $file -or $file -match '[\\/]' -or $file.StartsWith('.')) { throw 'The server sent an unexpected checksum file.' } $dir = Join-Path ([IO.Path]::GetTempPath()) ("hobfolk-" + [Guid]::NewGuid().ToString('N')) New-Item -ItemType Directory -Path $dir | Out-Null try { $path = Join-Path $dir $file Write-Host "Downloading $file..." Invoke-WebRequest -UseBasicParsing -Uri "$base/download/$target" -OutFile $path $actual = (Get-FileHash -Algorithm SHA256 -Path $path).Hash.ToLowerInvariant() if ($actual -ne $expected) { throw "The download does not match its SHA-256 (expected $expected, got $actual). Nothing was installed." } $updated = Test-Path (Join-Path $env:LOCALAPPDATA 'Programs\Hobfolk\Hobfolk.exe') if (Get-Process -Name Hobfolk -ErrorAction SilentlyContinue) { Write-Host 'Hobfolk is open: quit it before opening the new version.' } Write-Host 'SHA-256 checked. Installing...' $process = Start-Process -FilePath $path -ArgumentList '/S' -Wait -PassThru if ($process.ExitCode -ne 0) { throw "The installer ended with code $($process.ExitCode)." } Write-Host '' if ($updated) { Write-Host 'Hobfolk is updated: open it from the Start menu.' } else { Write-Host 'Hobfolk is installed: open it from the Start menu.' Write-Host 'Then sign in with your Hobfolk account, open a folder and ask in one sentence.' } } finally { Remove-Item -Recurse -Force -Path $dir -ErrorAction SilentlyContinue } }