mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2025-01-15 17:30:37 -06:00
improve automation
- runs everything at the same time - does not work without displaying ui
This commit is contained in:
parent
cfb9edbce7
commit
ae87100c61
@ -6,13 +6,21 @@ function Invoke-WPFFeatureInstall {
|
|||||||
|
|
||||||
#>
|
#>
|
||||||
|
|
||||||
|
param (
|
||||||
|
$FeatureConfig
|
||||||
|
)
|
||||||
|
|
||||||
if($sync.ProcessRunning) {
|
if($sync.ProcessRunning) {
|
||||||
$msg = "[Invoke-WPFFeatureInstall] Install process is currently running."
|
$msg = "[Invoke-WPFFeatureInstall] Install process is currently running."
|
||||||
[System.Windows.MessageBox]::Show($msg, "Winutil", [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Warning)
|
[System.Windows.MessageBox]::Show($msg, "Winutil", [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Warning)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($FeatureConfig) {
|
||||||
|
$Features = $FeatureConfig
|
||||||
|
} else {
|
||||||
$Features = (Get-WinUtilCheckBoxes)["WPFFeature"]
|
$Features = (Get-WinUtilCheckBoxes)["WPFFeature"]
|
||||||
|
}
|
||||||
|
|
||||||
Invoke-WPFRunspace -ArgumentList $Features -DebugPreference $DebugPreference -ScriptBlock {
|
Invoke-WPFRunspace -ArgumentList $Features -DebugPreference $DebugPreference -ScriptBlock {
|
||||||
param($Features, $DebugPreference)
|
param($Features, $DebugPreference)
|
||||||
|
@ -6,14 +6,22 @@ function Invoke-WPFInstall {
|
|||||||
|
|
||||||
#>
|
#>
|
||||||
|
|
||||||
|
param (
|
||||||
|
$InstallConfig
|
||||||
|
)
|
||||||
|
|
||||||
if($sync.ProcessRunning) {
|
if($sync.ProcessRunning) {
|
||||||
$msg = "[Invoke-WPFInstall] An Install process is currently running."
|
$msg = "[Invoke-WPFInstall] An Install process is currently running."
|
||||||
[System.Windows.MessageBox]::Show($msg, "Winutil", [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Warning)
|
[System.Windows.MessageBox]::Show($msg, "Winutil", [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Warning)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($InstallConfig) {
|
||||||
|
$PackagesToInstall = $InstallConfig
|
||||||
|
} else {
|
||||||
$PackagesToInstall = (Get-WinUtilCheckBoxes)["Install"]
|
$PackagesToInstall = (Get-WinUtilCheckBoxes)["Install"]
|
||||||
Write-Host $PackagesToInstall
|
}
|
||||||
|
|
||||||
if ($PackagesToInstall.Count -eq 0) {
|
if ($PackagesToInstall.Count -eq 0) {
|
||||||
$WarningMsg = "Please select the program(s) to install or upgrade"
|
$WarningMsg = "Please select the program(s) to install or upgrade"
|
||||||
[System.Windows.MessageBox]::Show($WarningMsg, $AppTitle, [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Warning)
|
[System.Windows.MessageBox]::Show($WarningMsg, $AppTitle, [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Warning)
|
||||||
|
@ -6,13 +6,21 @@ function Invoke-WPFtweaksbutton {
|
|||||||
|
|
||||||
#>
|
#>
|
||||||
|
|
||||||
|
param (
|
||||||
|
$TweaksConfig
|
||||||
|
)
|
||||||
|
|
||||||
if($sync.ProcessRunning) {
|
if($sync.ProcessRunning) {
|
||||||
$msg = "[Invoke-WPFtweaksbutton] Install process is currently running."
|
$msg = "[Invoke-WPFtweaksbutton] Install process is currently running."
|
||||||
[System.Windows.MessageBox]::Show($msg, "Winutil", [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Warning)
|
[System.Windows.MessageBox]::Show($msg, "Winutil", [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Warning)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($TweaksConfig) {
|
||||||
|
$Tweaks = $TweaksConfig
|
||||||
|
} else {
|
||||||
$Tweaks = (Get-WinUtilCheckBoxes)["WPFTweaks"]
|
$Tweaks = (Get-WinUtilCheckBoxes)["WPFTweaks"]
|
||||||
|
}
|
||||||
|
|
||||||
Set-WinUtilDNS -DNSProvider $sync["WPFchangedns"].text
|
Set-WinUtilDNS -DNSProvider $sync["WPFchangedns"].text
|
||||||
|
|
||||||
|
@ -322,38 +322,45 @@ Add-Type @"
|
|||||||
# maybe this is not the best place to load and execute config file?
|
# maybe this is not the best place to load and execute config file?
|
||||||
# maybe community can help?
|
# maybe community can help?
|
||||||
if ($PARAM_CONFIG) {
|
if ($PARAM_CONFIG) {
|
||||||
Invoke-WPFImpex -type "import" -Config $PARAM_CONFIG
|
|
||||||
if ($PARAM_RUN) {
|
if ($PARAM_RUN) {
|
||||||
while ($sync.ProcessRunning) {
|
$installConfig = Get-Content $PARAM_CONFIG -Raw | ConvertFrom-Json
|
||||||
Start-Sleep -Seconds 5
|
if ($installConfig.WPFTweaks) {
|
||||||
|
write-host "Running Tweaks"
|
||||||
|
Invoke-WPFtweaksbutton -TweaksConfig $installConfig.WPFTweaks
|
||||||
}
|
}
|
||||||
Start-Sleep -Seconds 5
|
if ($installConfig.WPFFeature) {
|
||||||
|
write-host "Installing Features"
|
||||||
Write-Host "Applying tweaks..."
|
Invoke-WPFFeatureInstall -FeatureConfig $installConfig.WPFFeature
|
||||||
Invoke-WPFtweaksbutton
|
|
||||||
while ($sync.ProcessRunning) {
|
|
||||||
Start-Sleep -Seconds 5
|
|
||||||
}
|
}
|
||||||
Start-Sleep -Seconds 5
|
if ($installConfig.WPFInstall) {
|
||||||
|
write-host "Installing Programs"
|
||||||
|
|
||||||
Write-Host "Installing features..."
|
# Create a new array to hold the combined install configurations
|
||||||
Invoke-WPFFeatureInstall
|
$combinedInstallConfig = @()
|
||||||
while ($sync.ProcessRunning) {
|
|
||||||
Start-Sleep -Seconds 5
|
# Iterate over each WPFInstall entry
|
||||||
|
for ($i = 0; $i -lt $installConfig.WPFInstall.Count; $i++) {
|
||||||
|
$wpfInstallEntry = $installConfig.WPFInstall[$i]
|
||||||
|
$installEntry = $installConfig.Install[$i]
|
||||||
|
|
||||||
|
# Create a new object with the combined values
|
||||||
|
$combinedEntry = @{
|
||||||
|
Name = $wpfInstallEntry
|
||||||
|
Winget = $installEntry.winget
|
||||||
|
Choco = $installEntry.choco
|
||||||
}
|
}
|
||||||
|
|
||||||
Start-Sleep -Seconds 5
|
# Add the combined entry to the array
|
||||||
Write-Host "Installing applications..."
|
$combinedInstallConfig += $combinedEntry
|
||||||
while ($sync.ProcessRunning) {
|
|
||||||
Start-Sleep -Seconds 1
|
|
||||||
}
|
|
||||||
Invoke-WPFInstall
|
|
||||||
Start-Sleep -Seconds 5
|
|
||||||
|
|
||||||
Write-Host "Done."
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Invoke the WPFInstall function with the combined configuration
|
||||||
|
Invoke-WPFInstall -InstallConfig $combinedInstallConfig
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Invoke-WPFImpex -type "import" -Config $PARAM_CONFIG
|
||||||
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
# Load Checkboxes and Labels outside of the Filter function only once on startup for performance reasons
|
# Load Checkboxes and Labels outside of the Filter function only once on startup for performance reasons
|
||||||
|
Loading…
Reference in New Issue
Block a user