diff --git a/docs/content/userguide/automation/_index.md b/docs/content/userguide/automation/_index.md index a868d81d..b540091b 100644 --- a/docs/content/userguide/automation/_index.md +++ b/docs/content/userguide/automation/_index.md @@ -16,7 +16,7 @@ To create a config file: Once you have exported a config, launch Winutil with it using this command: ```powershell -& ([ScriptBlock]::Create((irm "https://christitus.com/win"))) -Config "C:\Path\To\Config.json" -Run +& ([ScriptBlock]::Create((irm "https://christitus.com/win"))) -Config "C:\Path\To\Config.json" ``` This is useful for: diff --git a/functions/public/Invoke-WPFtweaksbutton.ps1 b/functions/public/Invoke-WPFtweaksbutton.ps1 index 192ca284..a0f9accc 100644 --- a/functions/public/Invoke-WPFtweaksbutton.ps1 +++ b/functions/public/Invoke-WPFtweaksbutton.ps1 @@ -14,6 +14,9 @@ function Invoke-WPFtweaksbutton { $Tweaks = $sync.selectedTweaks $dnsProvider = $sync["WPFchangedns"].text + if (-not ($dnsProvider)) { + $dnsProvider = "Default" + } $restorePointTweak = "WPFTweaksRestorePoint" $restorePointSelected = $Tweaks -contains $restorePointTweak $tweaksToRun = @($Tweaks | Where-Object { $_ -ne $restorePointTweak }) diff --git a/functions/public/Invoke-WinUtilAutoRun.ps1 b/functions/public/Invoke-WinUtilAutoRun.ps1 index 022dae22..f9170522 100644 --- a/functions/public/Invoke-WinUtilAutoRun.ps1 +++ b/functions/public/Invoke-WinUtilAutoRun.ps1 @@ -6,43 +6,29 @@ function Invoke-WinUtilAutoRun { #> function BusyWait { - Start-Sleep -Seconds 5 + Start-Sleep -Milliseconds 100 while ($sync.ProcessRunning) { - Start-Sleep -Seconds 5 - } - } - - BusyWait - - Write-Host "Applying tweaks..." - Invoke-WPFtweaksbutton - BusyWait - - Write-Host "Applying toggles..." - $handle = Invoke-WPFRunspace -ScriptBlock { - $Toggles = $sync.selectedToggles - Write-Debug "Inside Number of toggles to process: $($Toggles.Count)" - - $sync.ProcessRunning = $true - - for ($i = 0; $i -lt $Tweaks.Count; $i++) { - Invoke-WinUtilTweaks $Toggles[$i] + Start-Sleep -Milliseconds 100 } - - $sync.ProcessRunning = $false - Write-Host "=================================" - Write-Host "-- Toggles are Finished ---" - Write-Host "=================================" } - BusyWait - Write-Host "Applying features..." - Invoke-WPFFeatureInstall - BusyWait + if ($sync.selectedTweaks.Count -gt 0) { + Write-Host "Applying tweaks..." + Invoke-WPFtweaksbutton + BusyWait + } - Write-Host "Installing applications..." - Invoke-WPFInstall - BusyWait + if ($sync.selectedFeatures.Count -gt 0) { + Write-Host "Applying features..." + Invoke-WPFFeatureInstall + BusyWait + } + + if ($sync.selectedApps.Count -gt 0) { + Write-Host "Installing applications..." + Invoke-WPFInstall + BusyWait + } Write-Host "Done." } diff --git a/scripts/main.ps1 b/scripts/main.ps1 index fecee8eb..d678f810 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -75,12 +75,8 @@ if ($PARAM_NOUI) { if ($PARAM_CONFIG -and -not [string]::IsNullOrWhiteSpace($PARAM_CONFIG)) { Write-Host "Running config file tasks..." Invoke-WPFImpex -type "import" -Config $PARAM_CONFIG - if ($PARAM_RUN) { - Invoke-WinUtilAutoRun - } - else { - Write-Host "Did you forget to add '--Run'?"; - } + Invoke-WinUtilAutoRun + $sync.runspace.Dispose() $sync.runspace.Close() [System.GC]::Collect() @@ -386,7 +382,7 @@ $sync["Form"].Add_ContentRendered({ if ($PARAM_CONFIG -and -not [string]::IsNullOrWhiteSpace($PARAM_CONFIG)) { Write-Host "Running config file tasks..." Invoke-WPFImpex -type "import" -Config $PARAM_CONFIG - if ($PARAM_RUN) { + Invoke-WPFRunspace -ScriptBlock { Invoke-WinUtilAutoRun } } diff --git a/scripts/start.ps1 b/scripts/start.ps1 index 2e0221a9..d2c83834 100644 --- a/scripts/start.ps1 +++ b/scripts/start.ps1 @@ -8,7 +8,6 @@ param ( [string]$Config, - [switch]$Run, [switch]$Noui, [switch]$Offline ) @@ -17,12 +16,6 @@ if ($Config) { $PARAM_CONFIG = $Config } -$PARAM_RUN = $false -# Handle the -Run switch -if ($Run) { - $PARAM_RUN = $true -} - $PARAM_NOUI = $false if ($Noui) { $PARAM_NOUI = $true