mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2025-07-01 02:22:34 -05:00
Switch to PreferChocolatey Checkbox
This commit is contained in:
@ -29,19 +29,19 @@ function Install-WinUtilProgramChoco {
|
||||
throw "Private Function 'Install-WinUtilProgramChoco' expected Parameter 'ProgramsToInstall' to be of size 1 or greater, instead got $count,`nPlease double check your code and re-compile WinUtil."
|
||||
}
|
||||
|
||||
Write-Progress -Activity "$manage Applications" -Status "Starting" -PercentComplete 0
|
||||
|
||||
Write-Host "==========================================="
|
||||
Write-Host "-- Configuring Chocolatey pacakages ---"
|
||||
Write-Host "==========================================="
|
||||
Foreach ($Program in $ProgramsToInstall) {
|
||||
Write-Progress -Activity "$manage Applications" -Status "$manage $($Program.choco) $($x + 1) of $count" -PercentComplete $($x/$count*100)
|
||||
|
||||
if($manage -eq "Installing") {
|
||||
write-host "Starting install of $($Program.choco) with Chocolatey."
|
||||
try {
|
||||
$tryUpgrade = $false
|
||||
$installOutputFilePath = "$env:TEMP\Install-WinUtilProgramChoco.install-command.output.txt"
|
||||
New-Item -ItemType File -Path $installOutputFilePath
|
||||
$chocoInstallStatus = $(Start-Process -FilePath "choco" -ArgumentList "install $($Program.choco) -y" -Wait -PassThru -RedirectStandardOutput $installOutputFilePath).ExitCode
|
||||
$chocoInstallStatus = $(Start-Process -FilePath "choco" -ArgumentList "install $($Program.choco) -y" -Wait -PassThru -RedirectStandardOutput $installOutputFilePath -NoNewWindow).ExitCode
|
||||
if(($chocoInstallStatus -eq 0) -AND (Test-Path -Path $installOutputFilePath)) {
|
||||
$keywordsFound = Get-Content -Path $installOutputFilePath | Where-Object {$_ -match "reinstall" -OR $_ -match "already installed"}
|
||||
if ($keywordsFound) {
|
||||
@ -50,7 +50,10 @@ function Install-WinUtilProgramChoco {
|
||||
}
|
||||
# TODO: Implement the Upgrade part using 'choco upgrade' command, this will make choco consistent with WinGet, as WinGet tries to Upgrade when you use the install command.
|
||||
if ($tryUpgrade) {
|
||||
throw "Automatic Upgrade for Choco isn't implemented yet, a feature to make it consistent with WinGet, the install command using choco simply failed because $($Program.choco) is already installed."
|
||||
$chocoUpdateStatus = $(Start-Process -FilePath "choco" -ArgumentList "upgrade $($Program.choco) -y" -Wait -PassThru -RedirectStandardOutput $installOutputFilePath -NoNewWindow).ExitCode
|
||||
if ($chocoUpdateStatus -eq 0) {
|
||||
Write-Host "$($Program.choco) was updated successfully using Chocolatey."
|
||||
}
|
||||
}
|
||||
if(($chocoInstallStatus -eq 0) -AND ($tryUpgrade -eq $false)) {
|
||||
Write-Host "$($Program.choco) installed successfully using Chocolatey."
|
||||
@ -74,7 +77,7 @@ function Install-WinUtilProgramChoco {
|
||||
try {
|
||||
$uninstallOutputFilePath = "$env:TEMP\Install-WinUtilProgramChoco.uninstall-command.output.txt"
|
||||
New-Item -ItemType File -Path $uninstallOutputFilePath
|
||||
$chocoUninstallStatus = $(Start-Process -FilePath "choco" -ArgumentList "uninstall $($Program.choco) -y" -Wait -PassThru).ExitCode
|
||||
$chocoUninstallStatus = $(Start-Process -FilePath "choco" -ArgumentList "uninstall $($Program.choco) -y" -Wait -PassThru -NoNewWindow).ExitCode
|
||||
if($chocoUninstallStatus -eq 0) {
|
||||
Write-Host "$($Program.choco) uninstalled successfully using Chocolatey."
|
||||
$x++
|
||||
@ -92,7 +95,6 @@ function Install-WinUtilProgramChoco {
|
||||
}
|
||||
}
|
||||
}
|
||||
Write-Progress -Activity "$manage Applications" -Status "Finished" -Completed
|
||||
|
||||
# Cleanup leftovers files
|
||||
if(Test-Path -Path $installOutputFilePath) { Remove-Item -Path $installOutputFilePath }
|
||||
|
@ -1,35 +0,0 @@
|
||||
function Set-DownloadEngine {
|
||||
$CheckBoxes = $sync.GetEnumerator() | Where-Object { $_.Value -is [System.Windows.Controls.CheckBox] }
|
||||
|
||||
foreach ($CheckBox in $CheckBoxes) {
|
||||
if ($CheckBox.Key.StartsWith("WPFInstall")) {
|
||||
Switch ($sync.DownloadEngine) {
|
||||
"Winget" {
|
||||
if ($($sync.configs.applications.$($CheckBox.Name).winget) -eq "na"){
|
||||
$CheckBox.Value.Visibility = "Collapsed"
|
||||
$sync."$($CheckBox.Key)Link".Visibility = "Collapsed"
|
||||
|
||||
}
|
||||
else{
|
||||
$CheckBox.Value.Visibility = "Visible"
|
||||
$sync."$($CheckBox.Key)Link".Visibility = "Visible"
|
||||
}
|
||||
}
|
||||
"Chocolatey"{
|
||||
if ($($sync.configs.applications.$($CheckBox.Name).chocolatey) -eq "na"){
|
||||
$CheckBox.Value.Visibility = "Collapsed"
|
||||
$sync."$($CheckBox.Key)Link".Visibility = "Collapsed"
|
||||
}
|
||||
else {
|
||||
$CheckBox.Value.Visibility = "Visible"
|
||||
$sync."$($CheckBox.Key)Link".Visibility = "Visible"
|
||||
}
|
||||
}
|
||||
default{
|
||||
$CheckBox.Value.Visibility = "Visible"
|
||||
$sync."$($CheckBox.Key)Link".Visibility = "Visible"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user