mirror of
https://github.com/ChrisTitusTech/winutil
synced 2026-04-05 22:28:31 +00:00
* cleaned up typo, fixes, grammatical and other related fixes (#2) * typo in Lightshot app name * remove trailing comma in applications.json * consistent capitalization of Windows, WinGet - only user-facing text - includes update to devdocs-generator.ps1, so docs for tweaks modifying registry will have `Windows settings` rather than `windows settings` * various fixes for typos, style, punctuation and capitalization * capitalize 'AM' * Update README.md change formatting for GitHub UI interaction form code format (` `) to bold md Co-authored-by: Jay <65828559+Jay-o-Way@users.noreply.github.com> * typos and wording in docs --------- Co-authored-by: Jay <65828559+Jay-o-Way@users.noreply.github.com>
57 lines
2.6 KiB
PowerShell
57 lines
2.6 KiB
PowerShell
function Invoke-WPFInstall {
|
|
<#
|
|
.SYNOPSIS
|
|
Installs the selected programs using winget, if one or more of the selected programs are already installed on the system, winget will try and perform an upgrade if there's a newer version to install.
|
|
#>
|
|
|
|
$PackagesToInstall = $sync.selectedApps | Foreach-Object { $sync.configs.applicationsHashtable.$_ }
|
|
|
|
|
|
if($sync.ProcessRunning) {
|
|
$msg = "[Invoke-WPFInstall] An Install process is currently running."
|
|
[System.Windows.MessageBox]::Show($msg, "Winutil", [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Warning)
|
|
return
|
|
}
|
|
|
|
if ($PackagesToInstall.Count -eq 0) {
|
|
$WarningMsg = "Please select the program(s) to install or upgrade."
|
|
[System.Windows.MessageBox]::Show($WarningMsg, $AppTitle, [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Warning)
|
|
return
|
|
}
|
|
|
|
$ManagerPreference = $sync.preferences.packagemanager
|
|
|
|
$handle = Invoke-WPFRunspace -ParameterList @(("PackagesToInstall", $PackagesToInstall),("ManagerPreference", $ManagerPreference)) -ScriptBlock {
|
|
param($PackagesToInstall, $ManagerPreference)
|
|
|
|
$packagesSorted = Get-WinUtilSelectedPackages -PackageList $PackagesToInstall -Preference $ManagerPreference
|
|
|
|
$packagesWinget = $packagesSorted[[PackageManagers]::Winget]
|
|
$packagesChoco = $packagesSorted[[PackageManagers]::Choco]
|
|
|
|
try {
|
|
$sync.ProcessRunning = $true
|
|
if($packagesWinget.Count -gt 0 -and $packagesWinget -ne "0") {
|
|
Show-WPFInstallAppBusy -text "Installing apps..."
|
|
Install-WinUtilWinget
|
|
Install-WinUtilProgramWinget -Action Install -Programs $packagesWinget
|
|
}
|
|
if($packagesChoco.Count -gt 0) {
|
|
Install-WinUtilChoco
|
|
Install-WinUtilProgramChoco -Action Install -Programs $packagesChoco
|
|
}
|
|
Hide-WPFInstallAppBusy
|
|
Write-Host "==========================================="
|
|
Write-Host "-- Installs have finished ---"
|
|
Write-Host "==========================================="
|
|
Invoke-WPFUIThread -ScriptBlock { Set-WinUtilTaskbaritem -state "None" -overlay "checkmark" }
|
|
} catch {
|
|
Write-Host "==========================================="
|
|
Write-Host "Error: $_"
|
|
Write-Host "==========================================="
|
|
Invoke-WPFUIThread -ScriptBlock { Set-WinUtilTaskbaritem -state "Error" -overlay "warning" }
|
|
}
|
|
$sync.ProcessRunning = $False
|
|
}
|
|
}
|