# StreamZH - one app for your whole media pipeline. # Copyright (c) 2026 The StreamZH Authors. # SPDX-License-Identifier: GPL-3.0-only # # Installs or updates StreamZH on Windows with one command in PowerShell: # # irm https://streamzh.com/install.ps1 | iex # # What it does: downloads the current Windows installer from GitHub, checks it against the release's SHA256SUMS, # runs it (Windows asks once for administrator rights), installs StreamZH as a Windows service with a tray icon, # allows port 9797 in the Windows Firewall for private networks only, and opens StreamZH in your browser. # Running it again updates StreamZH; settings and data stay. Nothing else is changed or sent. # Read it first if you like: https://streamzh.com/install.ps1 # Everything runs inside this block, so a download that breaks off half way does nothing. & { $ErrorActionPreference = 'Stop' $ProgressPreference = 'SilentlyContinue' $site = if ($env:STREAMZH_SITE) { $env:STREAMZH_SITE } else { 'https://streamzh.com' } $port = 9797 function Say([string] $text) { Write-Host '==> ' -ForegroundColor Red -NoNewline; Write-Host $text } function Info([string] $text) { Write-Host " $text" } try { [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12 } catch { } if (-not [Environment]::Is64BitOperatingSystem) { throw 'StreamZH needs 64-bit Windows.' } if ($env:PROCESSOR_ARCHITECTURE -eq 'ARM64' -or $env:PROCESSOR_ARCHITEW6432 -eq 'ARM64') { Info 'Windows on ARM runs the x64 version through emulation.' } # /download/ on the site redirects to the file on GitHub; the redirect names the current release. function Resolve-Download([string] $target) { $request = [Net.HttpWebRequest]::Create("$site/download/$target") $request.AllowAutoRedirect = $false $request.Method = 'HEAD' $response = $request.GetResponse() try { $location = $response.Headers['Location'] if (-not $location -or -not $location.StartsWith('https://github.com/StreamZH/StreamZH/releases/download/')) { throw "Unexpected download address for ${target}: $location" } return $location } finally { $response.Close() } } $tmp = Join-Path ([IO.Path]::GetTempPath()) ('streamzh-' + [Guid]::NewGuid().ToString('N')) New-Item -ItemType Directory -Path $tmp | Out-Null try { Say 'Downloading StreamZH for Windows' $setupUrl = Resolve-Download 'windows' $sumsUrl = Resolve-Download 'checksums' $name = [IO.Path]::GetFileName(([Uri] $setupUrl).AbsolutePath) $setup = Join-Path $tmp $name $sums = Join-Path $tmp 'SHA256SUMS' Invoke-WebRequest -Uri $sumsUrl -OutFile $sums -UseBasicParsing Invoke-WebRequest -Uri $setupUrl -OutFile $setup -UseBasicParsing Info ('Version: ' + ($name -replace '^StreamZH-', '' -replace '-win-x64-setup\.exe$', '')) $expected = $null foreach ($line in Get-Content -Path $sums) { $parts = $line.Trim() -split '\s+', 2 if ($parts.Count -eq 2 -and $parts[1].TrimStart('*') -eq $name) { $expected = $parts[0].ToLowerInvariant() } } if (-not $expected) { throw "$name is not listed in SHA256SUMS." } $actual = (Get-FileHash -Path $setup -Algorithm SHA256).Hash.ToLowerInvariant() if ($actual -ne $expected) { throw "Checksum mismatch for $name. Nothing was installed." } Info "Checksum OK ($name)" if ($env:STREAMZH_DRY_RUN) { Say "Dry run: $name checked, not installed"; return } Say 'Installing (confirm the Windows prompt for administrator rights)' $arguments = @('/SILENT', '/SUPPRESSMSGBOXES', '/NORESTART', '/TASKS="service,firewall"') try { $process = Start-Process -FilePath $setup -ArgumentList $arguments -Verb RunAs -Wait -PassThru } catch { throw 'The installation was cancelled (no administrator rights given).' } if ($process.ExitCode -ne 0) { throw "The installer ended with code $($process.ExitCode)." } Say 'Starting StreamZH' $url = "http://localhost:$port" $up = $false for ($i = 0; $i -lt 60 -and -not $up; $i++) { try { if ((Invoke-WebRequest -Uri "$url/health" -UseBasicParsing -TimeoutSec 2).StatusCode -eq 200) { $up = $true } } catch { Start-Sleep -Seconds 1 } } Write-Host '' if ($up) { Start-Process $url Say "StreamZH is running: $url" Info 'Create the owner account in the browser that just opened.' } else { Say "StreamZH is installed. Open $url in a moment." } Info "From other devices on your network: http://$($env:COMPUTERNAME.ToLowerInvariant()):$port" } finally { Remove-Item -Path $tmp -Recurse -Force -ErrorAction SilentlyContinue } }