installer: fix wintun hash check, pre-install exit code, WinForms guard, cmake arch
This commit is contained in:
parent
6f5e7bcfb3
commit
cd3f99b0e4
1 changed files with 24 additions and 9 deletions
|
|
@ -5,11 +5,29 @@ param()
|
||||||
|
|
||||||
$ErrorActionPreference = "Stop"
|
$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-Info { Write-Host $args -ForegroundColor Cyan }
|
||||||
function Write-Success { Write-Host $args -ForegroundColor Green }
|
function Write-Success { Write-Host $args -ForegroundColor Green }
|
||||||
function Write-Warning { Write-Host $args -ForegroundColor Yellow }
|
function Write-Warning { Write-Host $args -ForegroundColor Yellow }
|
||||||
function Write-Error { Write-Host $args -ForegroundColor Red }
|
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 {
|
try {
|
||||||
Write-Info "=== DragonMoonlight Pre-Installation Checks ==="
|
Write-Info "=== DragonMoonlight Pre-Installation Checks ==="
|
||||||
|
|
||||||
|
|
@ -17,11 +35,10 @@ try {
|
||||||
$isElevated = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")
|
$isElevated = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")
|
||||||
if (-not $isElevated) {
|
if (-not $isElevated) {
|
||||||
Write-Error "This script must run elevated (as Administrator). Installation cannot proceed."
|
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.",
|
"DragonMoonlight installation failed.`r`nThis installer requires Administrator privileges.",
|
||||||
"Installation Error",
|
"Installation Error",
|
||||||
[Windows.Forms.MessageBoxButtons]::OK,
|
[System.Windows.Forms.MessageBoxIcon]::Error
|
||||||
[Windows.Forms.MessageBoxIcon]::Error
|
|
||||||
)
|
)
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
@ -39,11 +56,10 @@ try {
|
||||||
Write-Error "DragonMoonlight requires Windows 10 (Build 19041/2004) or later."
|
Write-Error "DragonMoonlight requires Windows 10 (Build 19041/2004) or later."
|
||||||
Write-Error "Current build: $buildNumber"
|
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.",
|
"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",
|
"Unsupported Windows Version",
|
||||||
[Windows.Forms.MessageBoxButtons]::OK,
|
[System.Windows.Forms.MessageBoxIcon]::Error
|
||||||
[Windows.Forms.MessageBoxIcon]::Error
|
|
||||||
)
|
)
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
@ -82,11 +98,10 @@ try {
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
Write-Error "Pre-installation check failed: $_"
|
Write-Error "Pre-installation check failed: $_"
|
||||||
[Windows.Forms.MessageBox]::Show(
|
Show-Dialog(
|
||||||
"Pre-installation check failed:`r`n`r`n$_",
|
"Pre-installation check failed:`r`n`r`n$_",
|
||||||
"Installation Error",
|
"Installation Error",
|
||||||
[Windows.Forms.MessageBoxButtons]::OK,
|
[System.Windows.Forms.MessageBoxIcon]::Error
|
||||||
[Windows.Forms.MessageBoxIcon]::Error
|
|
||||||
)
|
)
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue