diff --git a/functions/private/Test-WinUtilInternetConnection.ps1 b/functions/private/Test-WinUtilInternetConnection.ps1 deleted file mode 100644 index d2aaca4a..00000000 --- a/functions/private/Test-WinUtilInternetConnection.ps1 +++ /dev/null @@ -1,26 +0,0 @@ -function Test-WinUtilInternetConnection { - <# - .SYNOPSIS - Tests if the computer has internet connectivity - .OUTPUTS - Boolean - True if connected, False if offline - #> - try { - # Test multiple reliable endpoints - $testSites = @( - "8.8.8.8", # Google DNS - "1.1.1.1", # Cloudflare DNS - "208.67.222.222" # OpenDNS - ) - - foreach ($site in $testSites) { - if (Test-Connection -ComputerName $site -Count 1 -Quiet -ErrorAction SilentlyContinue) { - return $true - } - } - return $false - } - catch { - return $false - } -} diff --git a/scripts/main.ps1 b/scripts/main.ps1 index 4f29b5a7..ba7ecd14 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -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 diff --git a/scripts/start.ps1 b/scripts/start.ps1 index 02c2c95d..44766a22 100644 --- a/scripts/start.ps1 +++ b/scripts/start.ps1 @@ -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." diff --git a/xaml/inputXML.xaml b/xaml/inputXML.xaml index 7c45ac9e..a4667e2c 100644 --- a/xaml/inputXML.xaml +++ b/xaml/inputXML.xaml @@ -943,13 +943,19 @@ + - + + + + + @@ -1192,7 +1198,7 @@ - +