Skip to content

Commit ae87100

Browse files
committed
improve automation
- runs everything at the same time - does not work without displaying ui
1 parent cfb9edb commit ae87100

File tree

4 files changed

+61
-30
lines changed

4 files changed

+61
-30
lines changed

functions/public/Invoke-WPFFeatureInstall.ps1

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,21 @@ function Invoke-WPFFeatureInstall {
66
77
#>
88

9+
param (
10+
$FeatureConfig
11+
)
12+
913
if($sync.ProcessRunning) {
1014
$msg = "[Invoke-WPFFeatureInstall] Install process is currently running."
1115
[System.Windows.MessageBox]::Show($msg, "Winutil", [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Warning)
1216
return
1317
}
1418

15-
$Features = (Get-WinUtilCheckBoxes)["WPFFeature"]
19+
if ($FeatureConfig) {
20+
$Features = $FeatureConfig
21+
} else {
22+
$Features = (Get-WinUtilCheckBoxes)["WPFFeature"]
23+
}
1624

1725
Invoke-WPFRunspace -ArgumentList $Features -DebugPreference $DebugPreference -ScriptBlock {
1826
param($Features, $DebugPreference)

functions/public/Invoke-WPFInstall.ps1

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,22 @@ function Invoke-WPFInstall {
66
77
#>
88

9+
param (
10+
$InstallConfig
11+
)
12+
913
if($sync.ProcessRunning) {
1014
$msg = "[Invoke-WPFInstall] An Install process is currently running."
1115
[System.Windows.MessageBox]::Show($msg, "Winutil", [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Warning)
1216
return
1317
}
1418

15-
$PackagesToInstall = (Get-WinUtilCheckBoxes)["Install"]
16-
Write-Host $PackagesToInstall
19+
if ($InstallConfig) {
20+
$PackagesToInstall = $InstallConfig
21+
} else {
22+
$PackagesToInstall = (Get-WinUtilCheckBoxes)["Install"]
23+
}
24+
1725
if ($PackagesToInstall.Count -eq 0) {
1826
$WarningMsg = "Please select the program(s) to install or upgrade"
1927
[System.Windows.MessageBox]::Show($WarningMsg, $AppTitle, [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Warning)

functions/public/Invoke-WPFtweaksbutton.ps1

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,21 @@ function Invoke-WPFtweaksbutton {
66
77
#>
88

9+
param (
10+
$TweaksConfig
11+
)
12+
913
if($sync.ProcessRunning) {
1014
$msg = "[Invoke-WPFtweaksbutton] Install process is currently running."
1115
[System.Windows.MessageBox]::Show($msg, "Winutil", [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Warning)
1216
return
1317
}
1418

15-
$Tweaks = (Get-WinUtilCheckBoxes)["WPFTweaks"]
19+
if ($TweaksConfig) {
20+
$Tweaks = $TweaksConfig
21+
} else {
22+
$Tweaks = (Get-WinUtilCheckBoxes)["WPFTweaks"]
23+
}
1624

1725
Set-WinUtilDNS -DNSProvider $sync["WPFchangedns"].text
1826

scripts/main.ps1

Lines changed: 33 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -322,38 +322,45 @@ Add-Type @"
322322
# maybe this is not the best place to load and execute config file?
323323
# maybe community can help?
324324
if ($PARAM_CONFIG) {
325-
Invoke-WPFImpex -type "import" -Config $PARAM_CONFIG
326325
if ($PARAM_RUN) {
327-
while ($sync.ProcessRunning) {
328-
Start-Sleep -Seconds 5
326+
$installConfig = Get-Content $PARAM_CONFIG -Raw | ConvertFrom-Json
327+
if ($installConfig.WPFTweaks) {
328+
write-host "Running Tweaks"
329+
Invoke-WPFtweaksbutton -TweaksConfig $installConfig.WPFTweaks
329330
}
330-
Start-Sleep -Seconds 5
331-
332-
Write-Host "Applying tweaks..."
333-
Invoke-WPFtweaksbutton
334-
while ($sync.ProcessRunning) {
335-
Start-Sleep -Seconds 5
336-
}
337-
Start-Sleep -Seconds 5
338-
339-
Write-Host "Installing features..."
340-
Invoke-WPFFeatureInstall
341-
while ($sync.ProcessRunning) {
342-
Start-Sleep -Seconds 5
331+
if ($installConfig.WPFFeature) {
332+
write-host "Installing Features"
333+
Invoke-WPFFeatureInstall -FeatureConfig $installConfig.WPFFeature
343334
}
344-
345-
Start-Sleep -Seconds 5
346-
Write-Host "Installing applications..."
347-
while ($sync.ProcessRunning) {
348-
Start-Sleep -Seconds 1
335+
if ($installConfig.WPFInstall) {
336+
write-host "Installing Programs"
337+
338+
# Create a new array to hold the combined install configurations
339+
$combinedInstallConfig = @()
340+
341+
# Iterate over each WPFInstall entry
342+
for ($i = 0; $i -lt $installConfig.WPFInstall.Count; $i++) {
343+
$wpfInstallEntry = $installConfig.WPFInstall[$i]
344+
$installEntry = $installConfig.Install[$i]
345+
346+
# Create a new object with the combined values
347+
$combinedEntry = @{
348+
Name = $wpfInstallEntry
349+
Winget = $installEntry.winget
350+
Choco = $installEntry.choco
351+
}
352+
353+
# Add the combined entry to the array
354+
$combinedInstallConfig += $combinedEntry
355+
}
356+
357+
# Invoke the WPFInstall function with the combined configuration
358+
Invoke-WPFInstall -InstallConfig $combinedInstallConfig
349359
}
350-
Invoke-WPFInstall
351-
Start-Sleep -Seconds 5
352-
353-
Write-Host "Done."
360+
} else {
361+
Invoke-WPFImpex -type "import" -Config $PARAM_CONFIG
354362
}
355363
}
356-
357364
})
358365

359366
# Load Checkboxes and Labels outside of the Filter function only once on startup for performance reasons

0 commit comments

Comments
 (0)