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,18 +22,17 @@ Function Install-WinUtilProgramWinget {
|
|||||||
[Parameter(Position=1)]
|
[Parameter(Position=1)]
|
||||||
[String]$manage = "Installing"
|
[String]$manage = "Installing"
|
||||||
)
|
)
|
||||||
|
$x = 0
|
||||||
$count = $ProgramsToInstall.Count
|
$count = $ProgramsToInstall.Count
|
||||||
|
|
||||||
Write-Progress -Activity "$manage Applications" -Status "Starting" -PercentComplete 0
|
Write-Progress -Activity "$manage Applications" -Status "Starting" -PercentComplete 0
|
||||||
Write-Host "==========================================="
|
Write-Host "==========================================="
|
||||||
Write-Host "-- Configuring winget packages ---"
|
Write-Host "-- Configuring winget packages ---"
|
||||||
Write-Host "==========================================="
|
Write-Host "==========================================="
|
||||||
for ($i = 0; $i -le $ProgramsToInstall.Count; $i++) {
|
Foreach ($Program in $ProgramsToInstall){
|
||||||
$Program = $ProgramsToInstall[$i]
|
|
||||||
$failedPackages = @()
|
$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") {
|
if($manage -eq "Installing"){
|
||||||
# Install package via ID, if it fails try again with different scope and then with an unelevated prompt.
|
# 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.
|
# Since Install-WinGetPackage might not be directly available, we use winget install command as a workaround.
|
||||||
# Winget, not all installers honor any of the following: System-wide, User Installs, or Unelevated Prompt OR Silent Install Mode.
|
# Winget, not all installers honor any of the following: System-wide, User Installs, or Unelevated Prompt OR Silent Install Mode.
|
||||||
@ -41,21 +40,21 @@ Function Install-WinUtilProgramWinget {
|
|||||||
Write-Host "Starting install of $($Program.winget) with winget."
|
Write-Host "Starting install of $($Program.winget) with winget."
|
||||||
try {
|
try {
|
||||||
$status = $(Start-Process -FilePath "winget" -ArgumentList "install --id $($Program.winget) --silent --accept-source-agreements --accept-package-agreements" -Wait -PassThru -NoNewWindow).ExitCode
|
$status = $(Start-Process -FilePath "winget" -ArgumentList "install --id $($Program.winget) --silent --accept-source-agreements --accept-package-agreements" -Wait -PassThru -NoNewWindow).ExitCode
|
||||||
if($status -eq 0) {
|
if($status -eq 0){
|
||||||
Write-Host "$($Program.winget) installed successfully."
|
Write-Host "$($Program.winget) installed successfully."
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if ($status -eq -1978335189) {
|
if ($status -eq -1978335189){
|
||||||
Write-Host "$($Program.winget) No applicable update found"
|
Write-Host "$($Program.winget) No applicable update found"
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
Write-Host "Attempt with User scope"
|
Write-Host "Attempt with User scope"
|
||||||
$status = $(Start-Process -FilePath "winget" -ArgumentList "install --id $($Program.winget) --scope user --silent --accept-source-agreements --accept-package-agreements" -Wait -PassThru -NoNewWindow).ExitCode
|
$status = $(Start-Process -FilePath "winget" -ArgumentList "install --id $($Program.winget) --scope user --silent --accept-source-agreements --accept-package-agreements" -Wait -PassThru -NoNewWindow).ExitCode
|
||||||
if($status -eq 0) {
|
if($status -eq 0){
|
||||||
Write-Host "$($Program.winget) installed successfully with User scope."
|
Write-Host "$($Program.winget) installed successfully with User scope."
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if ($status -eq -1978335189) {
|
if ($status -eq -1978335189){
|
||||||
Write-Host "$($Program.winget) No applicable update found"
|
Write-Host "$($Program.winget) No applicable update found"
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -69,11 +68,11 @@ Function Install-WinUtilProgramWinget {
|
|||||||
} else {
|
} else {
|
||||||
Write-Host "Skipping installation with specific user credentials."
|
Write-Host "Skipping installation with specific user credentials."
|
||||||
}
|
}
|
||||||
if($status -eq 0) {
|
if($status -eq 0){
|
||||||
Write-Host "$($Program.winget) installed successfully with User prompt."
|
Write-Host "$($Program.winget) installed successfully with User prompt."
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if ($status -eq -1978335189) {
|
if ($status -eq -1978335189){
|
||||||
Write-Host "$($Program.winget) No applicable update found"
|
Write-Host "$($Program.winget) No applicable update found"
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -82,11 +81,11 @@ Function Install-WinUtilProgramWinget {
|
|||||||
$failedPackages += $Program
|
$failedPackages += $Program
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elseif($manage -eq "Uninstalling") {
|
if($manage -eq "Uninstalling"){
|
||||||
# Uninstall package via ID using winget directly.
|
# Uninstall package via ID using winget directly.
|
||||||
try {
|
try {
|
||||||
$status = $(Start-Process -FilePath "winget" -ArgumentList "uninstall --id $($Program.winget) --silent" -Wait -PassThru -NoNewWindow).ExitCode
|
$status = $(Start-Process -FilePath "winget" -ArgumentList "uninstall --id $($Program.winget) --silent" -Wait -PassThru -NoNewWindow).ExitCode
|
||||||
if($status -ne 0) {
|
if($status -ne 0){
|
||||||
Write-Host "Failed to uninstall $($Program.winget)."
|
Write-Host "Failed to uninstall $($Program.winget)."
|
||||||
} else {
|
} else {
|
||||||
Write-Host "$($Program.winget) uninstalled successfully."
|
Write-Host "$($Program.winget) uninstalled successfully."
|
||||||
@ -97,9 +96,7 @@ Function Install-WinUtilProgramWinget {
|
|||||||
$failedPackages += $Program
|
$failedPackages += $Program
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
$X++
|
||||||
throw "[Install-WinUtilProgramWinget] Invalid Value for Parameter 'manage', Provided Value is: $manage"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Write-Progress -Activity "$manage Applications" -Status "Finished" -Completed
|
Write-Progress -Activity "$manage Applications" -Status "Finished" -Completed
|
||||||
return $failedPackages;
|
return $failedPackages;
|
||||||
|
Loading…
Reference in New Issue
Block a user