Fix offline mode (#4153)

* Fix usb error on drive with no existing partitions

* fix offline mode

* Add offline banner
This commit is contained in:
Chris Titus
2026-03-04 12:21:18 -06:00
committed by GitHub
parent 7f46e8d60d
commit df17ca4695
4 changed files with 20 additions and 33 deletions

View File

@@ -15,12 +15,14 @@ $maxthreads = [int]$env:NUMBER_OF_PROCESSORS
$hashVars = New-object System.Management.Automation.Runspaces.SessionStateVariableEntry -ArgumentList 'sync',$sync,$Null
$debugVar = New-object System.Management.Automation.Runspaces.SessionStateVariableEntry -ArgumentList 'DebugPreference',$DebugPreference,$Null
$uiVar = New-object System.Management.Automation.Runspaces.SessionStateVariableEntry -ArgumentList 'PARAM_NOUI',$PARAM_NOUI,$Null
$offlineVar = New-object System.Management.Automation.Runspaces.SessionStateVariableEntry -ArgumentList 'PARAM_OFFLINE',$PARAM_OFFLINE,$Null
$InitialSessionState = [System.Management.Automation.Runspaces.InitialSessionState]::CreateDefault()
# Add the variable to the session state
$InitialSessionState.Variables.Add($hashVars)
$InitialSessionState.Variables.Add($debugVar)
$InitialSessionState.Variables.Add($uiVar)
$InitialSessionState.Variables.Add($offlineVar)
# Get every private function and add them to the session state
$functions = Get-ChildItem function:\ | Where-Object { $_.Name -imatch 'winutil|WPF' }
@@ -350,11 +352,10 @@ $sync["Form"].Add_ContentRendered({
Write-Debug "Unable to retrieve information about the primary monitor."
}
# Check internet connectivity and disable install tab if offline
#$isOnline = Test-WinUtilInternetConnection
$isOnline = $true # Temporarily force online mode until we can resolve false negatives
if ($PARAM_OFFLINE) {
# Show offline banner
$sync.WPFOfflineBanner.Visibility = [System.Windows.Visibility]::Visible
if (-not $isOnline) {
# Disable the install tab
$sync.WPFTab1BT.IsEnabled = $false
$sync.WPFTab1BT.Opacity = 0.5

View File

@@ -9,7 +9,8 @@
param (
[string]$Config,
[switch]$Run,
[switch]$Noui
[switch]$Noui,
[switch]$Offline
)
if ($Config) {
@@ -27,6 +28,11 @@ if ($Noui) {
$PARAM_NOUI = $true
}
$PARAM_OFFLINE = $false
if ($Offline) {
$PARAM_OFFLINE = $true
}
if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
Write-Output "Winutil needs to be run as Administrator. Attempting to relaunch."