mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2025-01-03 11:34:54 -06:00
8c91bfca2d
- Removed Get-LatestHash from Install-WinUtilWinget.ps1, replaced by Get-WinUtilWingetLatest.ps1. - Added new Winget Install method in case of choco failing to install. Environment refresh line included. - Get-WinUtilWingetPrerequisites added: Downloads the prerequisites required for the latest version of Winget. - Get-WinUtilWingetLatest added: Uses the GitHub API to find the latest version of Winget and download it along with the accompanied License1.xml file. Fixes: - Removed --scope=machine from winget install command in Install-WinUtilProgramWinget. Non-UWP Apps fail to install if scope is set to machine. Error code: 0x80070005. More information commented in file.
48 lines
1.6 KiB
PowerShell
48 lines
1.6 KiB
PowerShell
Function Install-WinUtilProgramWinget {
|
|
|
|
<#
|
|
|
|
.SYNOPSIS
|
|
Manages the provided programs using Winget
|
|
|
|
.PARAMETER ProgramsToInstall
|
|
A list of programs to manage
|
|
|
|
.PARAMETER manage
|
|
The action to perform on the programs, can be either 'Installing' or 'Uninstalling'
|
|
|
|
.NOTES
|
|
The triple quotes are required any time you need a " in a normal script block.
|
|
|
|
#>
|
|
|
|
param(
|
|
$ProgramsToInstall,
|
|
$manage = "Installing"
|
|
)
|
|
|
|
$x = 0
|
|
$count = $($ProgramsToInstall -split ",").Count
|
|
|
|
Write-Progress -Activity "$manage Applications" -Status "Starting" -PercentComplete 0
|
|
|
|
Foreach ($Program in $($ProgramsToInstall -split ",")){
|
|
|
|
Write-Progress -Activity "$manage Applications" -Status "$manage $Program $($x + 1) of $count" -PercentComplete $($x/$count*100)
|
|
if($manage -eq "Installing"){
|
|
# --scope=machine when installing non-UWP apps with winget fails with error code 0x80070005.
|
|
# Removed argument while testing new Winget install method.
|
|
# Open issue on winget-cli github repo: https://github.com/microsoft/winget-cli/issues/3936
|
|
Start-Process -FilePath winget -ArgumentList "install -e --accept-source-agreements --accept-package-agreements --silent $Program" -NoNewWindow -Wait
|
|
}
|
|
if($manage -eq "Uninstalling"){
|
|
Start-Process -FilePath winget -ArgumentList "uninstall -e --accept-source-agreements --purge --force --silent $Program" -NoNewWindow -Wait
|
|
}
|
|
|
|
$X++
|
|
}
|
|
|
|
Write-Progress -Activity "$manage Applications" -Status "Finished" -Completed
|
|
|
|
}
|