mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2024-11-14 22:55:52 -06:00
Winget Reversion
A reversion was needed on winget install because a for loop was installing the latest winget submitted app as it ran over.
This commit is contained in:
parent
5d3d47eeb5
commit
c90363181c
@ -22,17 +22,16 @@ Function Install-WinUtilProgramWinget {
|
||||
[Parameter(Position=1)]
|
||||
[String]$manage = "Installing"
|
||||
)
|
||||
|
||||
$x = 0
|
||||
$count = $ProgramsToInstall.Count
|
||||
|
||||
Write-Progress -Activity "$manage Applications" -Status "Starting" -PercentComplete 0
|
||||
Write-Host "==========================================="
|
||||
Write-Host "-- Configuring winget packages ---"
|
||||
Write-Host "==========================================="
|
||||
for ($i = 0; $i -le $ProgramsToInstall.Count; $i++) {
|
||||
$Program = $ProgramsToInstall[$i]
|
||||
Foreach ($Program in $ProgramsToInstall){
|
||||
$failedPackages = @()
|
||||
Write-Progress -Activity "$manage Applications" -Status "$manage $($Program.winget) $($i + 1) of $count" -PercentComplete $(($i/$count) * 100)
|
||||
Write-Progress -Activity "$manage Applications" -Status "$manage $($Program.winget) $($x + 1) of $count" -PercentComplete $($x/$count*100)
|
||||
if($manage -eq "Installing"){
|
||||
# Install package via ID, if it fails try again with different scope and then with an unelevated prompt.
|
||||
# Since Install-WinGetPackage might not be directly available, we use winget install command as a workaround.
|
||||
@ -82,7 +81,7 @@ Function Install-WinUtilProgramWinget {
|
||||
$failedPackages += $Program
|
||||
}
|
||||
}
|
||||
elseif($manage -eq "Uninstalling") {
|
||||
if($manage -eq "Uninstalling"){
|
||||
# Uninstall package via ID using winget directly.
|
||||
try {
|
||||
$status = $(Start-Process -FilePath "winget" -ArgumentList "uninstall --id $($Program.winget) --silent" -Wait -PassThru -NoNewWindow).ExitCode
|
||||
@ -97,9 +96,7 @@ Function Install-WinUtilProgramWinget {
|
||||
$failedPackages += $Program
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw "[Install-WinUtilProgramWinget] Invalid Value for Parameter 'manage', Provided Value is: $manage"
|
||||
}
|
||||
$X++
|
||||
}
|
||||
Write-Progress -Activity "$manage Applications" -Status "Finished" -Completed
|
||||
return $failedPackages;
|
||||
|
Loading…
Reference in New Issue
Block a user