diff --git a/functions/private/Set-WinUtilProgressbar.ps1 b/functions/private/Set-WinUtilProgressbar.ps1 index 2241e053..9ea815e2 100644 --- a/functions/private/Set-WinUtilProgressbar.ps1 +++ b/functions/private/Set-WinUtilProgressbar.ps1 @@ -14,10 +14,6 @@ function Set-WinUtilProgressbar{ [int]$Percent ) - if($PARAM_NOUI) { - return; - } - Invoke-WPFUIThread -ScriptBlock {$sync.progressBarTextBlock.Text = $label} Invoke-WPFUIThread -ScriptBlock {$sync.progressBarTextBlock.ToolTip = $label} if ($percent -lt 5 ) { diff --git a/functions/public/Invoke-WPFImpex.ps1 b/functions/public/Invoke-WPFImpex.ps1 index 08a6138f..ae15a2fa 100644 --- a/functions/public/Invoke-WPFImpex.ps1 +++ b/functions/public/Invoke-WPFImpex.ps1 @@ -92,17 +92,6 @@ function Invoke-WPFImpex { $sync.selectedFeatures = [System.Collections.Generic.List[string]]::new() Update-WinUtilSelections -flatJson $flattenedJson - - if (!$PARAM_NOUI) { - # Set flag so toggle Checked/Unchecked events don't trigger registry writes - # while we're programmatically restoring UI state from the imported config - $sync.ImportInProgress = $true - try { - Reset-WPFCheckBoxes -doToggles $true - } finally { - $sync.ImportInProgress = $false - } - } } } catch { Write-Error "An error occurred while importing: $_" diff --git a/functions/public/Invoke-WPFUIThread.ps1 b/functions/public/Invoke-WPFUIThread.ps1 index d5c1a465..8f42e286 100644 --- a/functions/public/Invoke-WPFUIThread.ps1 +++ b/functions/public/Invoke-WPFUIThread.ps1 @@ -1,21 +1,3 @@ -function Invoke-WPFUIThread { - <# - - .SYNOPSIS - Creates and runs a task on Winutil's WPF Forms thread. - - .PARAMETER ScriptBlock - The scriptblock to invoke in the thread - #> - - [CmdletBinding()] - Param ( - $ScriptBlock - ) - - if ($PARAM_NOUI) { - return; - } - +function Invoke-WPFUIThread ($ScriptBlock) { $sync.form.Dispatcher.Invoke([action]$ScriptBlock) } diff --git a/scripts/main.ps1 b/scripts/main.ps1 index dbd94a52..5e72b1e6 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -35,13 +35,11 @@ $maxthreads = [int]$env:NUMBER_OF_PROCESSORS # Create a new session state for parsing variables into our runspace $hashVars = New-object System.Management.Automation.Runspaces.SessionStateVariableEntry -ArgumentList 'sync',$sync,$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($uiVar) $InitialSessionState.Variables.Add($offlineVar) # Get every private function and add them to the session state @@ -91,8 +89,6 @@ $sync.configs.applications.PSObject.Properties | ForEach-Object { Set-Preferences if ($Preset) { - Show-CTTLogo - # Selects the tweaks from $Preset varible Update-WinUtilSelections -flatJson $sync.configs.preset.$Preset @@ -107,27 +103,17 @@ if ($Preset) { return } -if ($PARAM_NOUI) { - Show-CTTLogo - if ($PARAM_CONFIG -and -not [string]::IsNullOrWhiteSpace($PARAM_CONFIG)) { - Write-Host "Running config file tasks..." - Invoke-WPFImpex -type "import" -Config $PARAM_CONFIG - Invoke-WinUtilAutoRun +if ($Config) { + Invoke-WPFImpex -type "import" -Config $Config - $sync.runspace.Dispose() - $sync.runspace.Close() - [System.GC]::Collect() - Stop-Transcript - exit 1 - } - else { - Write-Host "Cannot automatically run without a config file provided." - $sync.runspace.Dispose() - $sync.runspace.Close() - [System.GC]::Collect() - Stop-Transcript - exit 1 - } + Invoke-WinUtilAutoRun + + # Cleanup and exit + $sync.runspace.Dispose() + $sync.runspace.Close() + [System.GC]::Collect() + Stop-Transcript + return } $inputXML = $inputXML -replace 'mc:Ignorable="d"', '' -replace "x:N", 'N' -replace '^