mirror of
https://github.com/ChrisTitusTech/winutil
synced 2026-06-09 15:57:27 +00:00
Remove -NoUi (#4572)
* Made -NoUi not exit the window * Update start.ps1 * Update main.ps1 * Update main.ps1 * Update Set-WinUtilProgressbar.ps1 * Update Invoke-WPFImpex.ps1 * Update Invoke-WPFUIThread.ps1 * Update start.ps1 * Update Invoke-WPFUIThread.ps1 * Update main.ps1 * Update main.ps1
This commit is contained in:
+17
-42
@@ -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 '^<Win.*', '<Window'
|
||||
@@ -400,27 +386,16 @@ $sync["Form"].Add_ContentRendered({
|
||||
Invoke-WPFTab "WPFTab1BT" # Default to install tab
|
||||
}
|
||||
|
||||
if (-not $PARAM_CONFIG -and (Test-Path "$winutildir\lastrun.json")) {
|
||||
try {
|
||||
$drifted = @(Get-Content "$winutildir\lastrun.json" | ConvertFrom-Json | Where-Object { $_ -notin (Invoke-WinUtilCurrentSystem -CheckBox "tweaks") })
|
||||
if ($drifted.Count -gt 0 -and [System.Windows.MessageBox]::Show("$($drifted.Count) tweak(s) were reverted since last run. Re-select them?", "Winutil", "YesNo", "Question") -eq "Yes") {
|
||||
Update-WinUtilSelections -flatJson $drifted
|
||||
Reset-WPFCheckBoxes -doToggles $false
|
||||
Invoke-WPFTab "WPFTab2BT"
|
||||
}
|
||||
} catch {}
|
||||
}
|
||||
|
||||
$sync["Form"].Focus()
|
||||
|
||||
if ($PARAM_CONFIG -and -not [string]::IsNullOrWhiteSpace($PARAM_CONFIG)) {
|
||||
Write-Host "Running config file tasks..."
|
||||
Invoke-WPFImpex -type "import" -Config $PARAM_CONFIG
|
||||
Invoke-WPFRunspace -ScriptBlock {
|
||||
Invoke-WinUtilAutoRun
|
||||
if (-not $Config -and (Test-Path "$winutildir\lastrun.json")) {
|
||||
$drifted = @(Get-Content "$winutildir\lastrun.json" | ConvertFrom-Json | Where-Object { $_ -notin (Invoke-WinUtilCurrentSystem -CheckBox "tweaks") })
|
||||
if ($drifted.Count -gt 0 -and [System.Windows.MessageBox]::Show("$($drifted.Count) tweak(s) were reverted since last run. Re-select them?", "Winutil", "YesNo", "Question") -eq "Yes") {
|
||||
Update-WinUtilSelections -flatJson $drifted
|
||||
Reset-WPFCheckBoxes -doToggles $false
|
||||
Invoke-WPFTab "WPFTab2BT"
|
||||
}
|
||||
}
|
||||
|
||||
$sync["Form"].Focus()
|
||||
})
|
||||
|
||||
# The SearchBarTimer is used to delay the search operation until the user has stopped typing for a short period
|
||||
|
||||
@@ -10,19 +10,9 @@ param (
|
||||
[string]$Config,
|
||||
[ValidateSet("Standard", "Minimal", "Advanced", "")]
|
||||
[string]$Preset,
|
||||
[switch]$Noui,
|
||||
[switch]$Offline
|
||||
)
|
||||
|
||||
if ($Config) {
|
||||
$PARAM_CONFIG = $Config
|
||||
}
|
||||
|
||||
$PARAM_NOUI = $false
|
||||
if ($Noui) {
|
||||
$PARAM_NOUI = $true
|
||||
}
|
||||
|
||||
$PARAM_OFFLINE = $false
|
||||
if ($Offline) {
|
||||
$PARAM_OFFLINE = $true
|
||||
|
||||
Reference in New Issue
Block a user