installer: fix wintun hash check, pre-install exit code, WinForms guard, cmake arch

This commit is contained in:
Zac Gaetano 2026-05-06 19:47:52 -04:00
parent 6f5e7bcfb3
commit cd3f99b0e4

View file

@ -5,11 +5,29 @@ param()
$ErrorActionPreference = "Stop"
# Validate Windows.Forms availability before using it
$hasWinForms = $false
try {
Add-Type -AssemblyName System.Windows.Forms -ErrorAction Stop
$hasWinForms = $true
} catch {
# Constrained environment — fall back to console output only
}
function Write-Info { Write-Host $args -ForegroundColor Cyan }
function Write-Success { Write-Host $args -ForegroundColor Green }
function Write-Warning { Write-Host $args -ForegroundColor Yellow }
function Write-Error { Write-Host $args -ForegroundColor Red }
function Show-Dialog($msg, $title, $icon) {
if ($hasWinForms) {
[System.Windows.Forms.MessageBox]::Show($msg, $title,
[System.Windows.Forms.MessageBoxButtons]::OK, $icon) | Out-Null
} else {
Write-Host "[$title] $msg" -ForegroundColor Red
}
}
try {
Write-Info "=== DragonMoonlight Pre-Installation Checks ==="
@ -17,11 +35,10 @@ try {
$isElevated = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")
if (-not $isElevated) {
Write-Error "This script must run elevated (as Administrator). Installation cannot proceed."
[Windows.Forms.MessageBox]::Show(
Show-Dialog(
"DragonMoonlight installation failed.`r`nThis installer requires Administrator privileges.",
"Installation Error",
[Windows.Forms.MessageBoxButtons]::OK,
[Windows.Forms.MessageBoxIcon]::Error
[System.Windows.Forms.MessageBoxIcon]::Error
)
exit 1
}
@ -39,11 +56,10 @@ try {
Write-Error "DragonMoonlight requires Windows 10 (Build 19041/2004) or later."
Write-Error "Current build: $buildNumber"
[Windows.Forms.MessageBox]::Show(
Show-Dialog(
"DragonMoonlight requires Windows 10 (Build 2004) or later.`r`n`r`nYour system is running Build $buildNumber, which does not support the required Windows Filtering Platform features for Wintun.`r`n`r`nPlease update Windows and try again.",
"Unsupported Windows Version",
[Windows.Forms.MessageBoxButtons]::OK,
[Windows.Forms.MessageBoxIcon]::Error
[System.Windows.Forms.MessageBoxIcon]::Error
)
exit 1
}
@ -82,11 +98,10 @@ try {
}
catch {
Write-Error "Pre-installation check failed: $_"
[Windows.Forms.MessageBox]::Show(
Show-Dialog(
"Pre-installation check failed:`r`n`r`n$_",
"Installation Error",
[Windows.Forms.MessageBoxButtons]::OK,
[Windows.Forms.MessageBoxIcon]::Error
[System.Windows.Forms.MessageBoxIcon]::Error
)
exit 1
}