Files
ThreadPilot/build/install-threadpilot.ps1
PrimeBuild-pc d86d7b1e8f security: close the remaining small gaps found by the audit
- Registry priority now writes IFEO\<exe>\PerfOptions\CpuPriorityClass, the value
  Windows reads (the old PriorityClass value did nothing and is cleaned up), and
  refuses an empty image name that would have targeted the IFEO root.
- Profile names must be plain file names, so they stay in the profiles folder.
- P/Invoke DLLs load from System32 only; explorer.exe is started by full path.
- The elevated restart passes arguments through ArgumentList (correct quoting).
- The single-instance mutex no longer crashes startup when another session owns it.
- Log size and retention are clamped and the size math is done in long.
- BinaryFormatter is disabled: the app only copies text to the clipboard.
- Two services registered but never resolved are no longer registered.
- build/install-threadpilot.ps1 verifies the installer against SHA256SUMS.txt.
2026-10-22 10:54:37 +02:00

55 lines
2.5 KiB
PowerShell

$ErrorActionPreference = "Stop"
# Verify administrator permissions for machine-wide installation changes.
if (-not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
Write-Warning "Please run this command in a PowerShell window opened as Administrator."
exit 1
}
Write-Host "Starting ThreadPilot installation..." -ForegroundColor Cyan
$releaseInfoUrl = "https://api.github.com/repos/PrimeBuild-pc/ThreadPilot/releases/latest"
$destPath = "$env:ProgramFiles\ThreadPilot"
if (-not (Test-Path -LiteralPath $destPath)) {
New-Item -ItemType Directory -Force -Path $destPath | Out-Null
}
Write-Host "Resolving latest ThreadPilot release..."
$release = Invoke-RestMethod -Uri $releaseInfoUrl
$asset = $release.assets | Where-Object { $_.name -like "*Setup.exe" } | Select-Object -First 1
if (-not $asset) {
throw "Could not find Setup.exe asset in the latest GitHub release."
}
$exePath = Join-Path $destPath $asset.name
$checksumAsset = $release.assets | Where-Object { $_.name -eq "SHA256SUMS.txt" } | Select-Object -First 1
if (-not $checksumAsset) {
throw "The latest release has no SHA256SUMS.txt, so the installer cannot be verified."
}
Write-Host "Downloading installer $($asset.name)..."
Invoke-WebRequest -Uri $asset.browser_download_url -OutFile $exePath -UseBasicParsing
$checksums = (Invoke-WebRequest -Uri $checksumAsset.browser_download_url -UseBasicParsing).Content
$expected = ($checksums -split "`n" | Where-Object { $_ -match "^([0-9a-fA-F]{64})\s+\*?$([regex]::Escape($asset.name))\s*$" } | ForEach-Object { $Matches[1] } | Select-Object -First 1)
$actual = (Get-FileHash -Path $exePath -Algorithm SHA256).Hash
if (-not $expected -or $actual -ne $expected) {
Remove-Item -LiteralPath $exePath -Force
throw "Installer checksum does not match SHA256SUMS.txt; the download was deleted."
}
# Optional machine PATH update for command-line convenience.
$currentPath = [Environment]::GetEnvironmentVariable("Path", "Machine")
if ($currentPath -notmatch [regex]::Escape($destPath)) {
[Environment]::SetEnvironmentVariable("Path", $currentPath + ";" + $destPath, "Machine")
Write-Host "Added install folder to machine PATH."
}
Write-Host "Running installer silently..."
Start-Process -FilePath $exePath -ArgumentList "/VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP-" -Wait
Write-Host "ThreadPilot installation completed successfully." -ForegroundColor Green