Upload pre-install.ps1
This commit is contained in:
parent
57371321e6
commit
bf81d10a9f
1 changed files with 92 additions and 0 deletions
92
package/win/pre-install.ps1
Normal file
92
package/win/pre-install.ps1
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
# DragonMoonlight Pre-Installation Check Script
|
||||
# Runs elevated before files are copied during installation
|
||||
|
||||
param()
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
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 }
|
||||
|
||||
try {
|
||||
Write-Info "=== DragonMoonlight Pre-Installation Checks ==="
|
||||
|
||||
# Check if running elevated
|
||||
$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(
|
||||
"DragonMoonlight installation failed.`r`nThis installer requires Administrator privileges.",
|
||||
"Installation Error",
|
||||
[Windows.Forms.MessageBoxButtons]::OK,
|
||||
[Windows.Forms.MessageBoxIcon]::Error
|
||||
)
|
||||
exit 1
|
||||
}
|
||||
Write-Success "✓ Running with elevated privileges"
|
||||
|
||||
# Check Windows version
|
||||
$osVersion = [Environment]::OSVersion.Version
|
||||
$buildNumber = [int](Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion' 'CurrentBuildNumber').CurrentBuildNumber
|
||||
|
||||
Write-Info "Windows version: $($osVersion.Major).$($osVersion.Minor) Build $buildNumber"
|
||||
|
||||
# Wintun requires Windows 10 2004 (Build 19041) or later
|
||||
if ($buildNumber -lt 19041) {
|
||||
Write-Error "This system does not meet the minimum requirements."
|
||||
Write-Error "DragonMoonlight requires Windows 10 (Build 19041/2004) or later."
|
||||
Write-Error "Current build: $buildNumber"
|
||||
|
||||
[Windows.Forms.MessageBox]::Show(
|
||||
"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
|
||||
)
|
||||
exit 1
|
||||
}
|
||||
|
||||
Write-Success "✓ Windows version check passed (Build $buildNumber >= 19041)"
|
||||
|
||||
# Warn about driver signature enforcement
|
||||
Write-Info "Checking driver signature enforcement status..."
|
||||
|
||||
try {
|
||||
$signingLevel = (Get-ItemProperty 'HKLM:\SYSTEM\CurrentControlSet\Control\SecureBoot\State' 'UEFISecureBootEnabled' -ErrorAction SilentlyContinue).UEFISecureBootEnabled
|
||||
if ($signingLevel -eq 1) {
|
||||
Write-Warning "⚠ Secure Boot is enabled. Ensure that Wintun driver signing certificate is trusted."
|
||||
} else {
|
||||
Write-Success "✓ Secure Boot is disabled or not detected"
|
||||
}
|
||||
} catch {
|
||||
Write-Info "Could not determine Secure Boot status (this is normal on non-UEFI systems)"
|
||||
}
|
||||
|
||||
# Log pre-install success to event log
|
||||
Write-Info "Logging pre-installation check to event log..."
|
||||
try {
|
||||
if (-not ([System.Diagnostics.EventLog]::SourceExists("DragonMoonlight"))) {
|
||||
New-EventLog -LogName Application -Source "DragonMoonlight" -ErrorAction SilentlyContinue
|
||||
}
|
||||
Write-EventLog -LogName Application -Source "DragonMoonlight" -EventId 1000 `
|
||||
-Message "DragonMoonlight pre-install check passed. Build: $buildNumber" -EntryType Information
|
||||
Write-Success "✓ Event log entry created"
|
||||
} catch {
|
||||
Write-Warning "Could not write to event log (non-critical): $_"
|
||||
}
|
||||
|
||||
Write-Success "=== Pre-installation checks completed successfully ==="
|
||||
exit 0
|
||||
}
|
||||
catch {
|
||||
Write-Error "Pre-installation check failed: $_"
|
||||
[Windows.Forms.MessageBox]::Show(
|
||||
"Pre-installation check failed:`r`n`r`n$_",
|
||||
"Installation Error",
|
||||
[Windows.Forms.MessageBoxButtons]::OK,
|
||||
[Windows.Forms.MessageBoxIcon]::Error
|
||||
)
|
||||
exit 1
|
||||
}
|
||||
Loading…
Reference in a new issue