revert winget

This commit is contained in:
Chris Titus 2024-02-07 18:11:40 -06:00
parent 92fa85768f
commit c842584cfe
7 changed files with 20 additions and 36 deletions

View File

@ -10,7 +10,7 @@ function Install-WinUtilChoco {
try { try {
Write-Host "Checking if Chocolatey is Installed..." Write-Host "Checking if Chocolatey is Installed..."
if((Test-WinUtilPackageManager -choco)){ if((Get-Command -Name choco -ErrorAction Ignore)) {
Write-Host "Chocolatey Already Installed" Write-Host "Chocolatey Already Installed"
return return
} }

View File

@ -30,7 +30,7 @@ Function Install-WinUtilProgramWinget {
Write-Progress -Activity "$manage Applications" -Status "$manage $Program $($x + 1) of $count" -PercentComplete $($x/$count*100) Write-Progress -Activity "$manage Applications" -Status "$manage $Program $($x + 1) of $count" -PercentComplete $($x/$count*100)
if($manage -eq "Installing"){ if($manage -eq "Installing"){
Start-Process -FilePath winget -ArgumentList "install -e --accept-source-agreements --accept-package-agreements --ignore-security-hash --disable-interactivity --silent $Program" -NoNewWindow -Wait Start-Process -FilePath winget -ArgumentList "install -e --accept-source-agreements --accept-package-agreements --scope=machine --silent $Program" -NoNewWindow -Wait
} }
if($manage -eq "Uninstalling"){ if($manage -eq "Uninstalling"){
Start-Process -FilePath winget -ArgumentList "uninstall -e --purge --force --silent $Program" -NoNewWindow -Wait Start-Process -FilePath winget -ArgumentList "uninstall -e --purge --force --silent $Program" -NoNewWindow -Wait
@ -41,4 +41,4 @@ Function Install-WinUtilProgramWinget {
Write-Progress -Activity "$manage Applications" -Status "Finished" -Completed Write-Progress -Activity "$manage Applications" -Status "Finished" -Completed
} }

View File

@ -22,7 +22,6 @@ function Install-WinUtilWinget {
if (Test-WinUtilPackageManager -winget) { if (Test-WinUtilPackageManager -winget) {
# Checks if winget executable exists and if the Windows Version is 1809 or higher # Checks if winget executable exists and if the Windows Version is 1809 or higher
Write-Host "Winget Already Installed" Write-Host "Winget Already Installed"
Start-Process -Verb runas -FilePath powershell.exe -ArgumentList "winget settings --enable InstallerHashOverride" -Wait -NoNewWindow
return return
} }
@ -40,19 +39,12 @@ function Install-WinUtilWinget {
return return
} }
Write-Host "Running Alternative Installers and Direct Installing" Write-Host "Running Alternative Installer and Direct Installing"
# Checks if winget is installed via Chocolatey Start-Process -Verb runas -FilePath powershell.exe -ArgumentList "choco install winget"
Start-Process -Verb runas -FilePath powershell.exe -ArgumentList "choco install winget --force" -Wait -NoNewWindow Write-Host "Winget Installed"
if (Test-WinUtilPackageManager -winget) {
# Checks if winget executable exists and if the Windows Version is 1809 or higher
Write-Host "Winget Installed via Chocolatey"
return
} else {
Write-Host "- Failed to install Winget via Chocolatey"
}
} }
Catch{ Catch{
throw [WingetFailedInstall]::new('Failed to install') throw [WingetFailedInstall]::new('Failed to install')
} }
} }

View File

@ -16,7 +16,7 @@ function Invoke-WPFGetInstalled {
return return
} }
if(!(Test-WinUtilPackageManager -winget) -and $checkbox -eq "winget"){ if(!(Get-Command -Name winget -ErrorAction SilentlyContinue) -and $checkbox -eq "winget"){
Write-Host "===========================================" Write-Host "==========================================="
Write-Host "-- Winget is not installed ---" Write-Host "-- Winget is not installed ---"
Write-Host "===========================================" Write-Host "==========================================="

View File

@ -35,7 +35,7 @@ function Invoke-WPFInstall {
} }
Catch { Catch {
Write-Host "===========================================" Write-Host "==========================================="
Write-Host "-- Winget failed to install ---" Write-Host "Error: $_"
Write-Host "===========================================" Write-Host "==========================================="
} }
Start-Sleep -Seconds 5 Start-Sleep -Seconds 5

View File

@ -5,7 +5,7 @@ function Invoke-WPFInstallUpgrade {
Invokes the function that upgrades all installed programs using winget Invokes the function that upgrades all installed programs using winget
#> #>
if(!(Test-WinUtilPackageManager -winget)){ if(!(Get-Command -Name winget -ErrorAction SilentlyContinue)){
Write-Host "===========================================" Write-Host "==========================================="
Write-Host "-- Winget is not installed ---" Write-Host "-- Winget is not installed ---"
Write-Host "===========================================" Write-Host "==========================================="

View File

@ -495,7 +495,7 @@ function Install-WinUtilChoco {
try { try {
Write-Host "Checking if Chocolatey is Installed..." Write-Host "Checking if Chocolatey is Installed..."
if((Test-WinUtilPackageManager -choco)){ if((Get-Command -Name choco -ErrorAction Ignore)) {
Write-Host "Chocolatey Already Installed" Write-Host "Chocolatey Already Installed"
return return
} }
@ -544,7 +544,7 @@ Function Install-WinUtilProgramWinget {
Write-Progress -Activity "$manage Applications" -Status "$manage $Program $($x + 1) of $count" -PercentComplete $($x/$count*100) Write-Progress -Activity "$manage Applications" -Status "$manage $Program $($x + 1) of $count" -PercentComplete $($x/$count*100)
if($manage -eq "Installing"){ if($manage -eq "Installing"){
Start-Process -FilePath winget -ArgumentList "install -e --accept-source-agreements --accept-package-agreements --ignore-security-hash --disable-interactivity --silent $Program" -NoNewWindow -Wait Start-Process -FilePath winget -ArgumentList "install -e --accept-source-agreements --accept-package-agreements --scope=machine --silent $Program" -NoNewWindow -Wait
} }
if($manage -eq "Uninstalling"){ if($manage -eq "Uninstalling"){
Start-Process -FilePath winget -ArgumentList "uninstall -e --purge --force --silent $Program" -NoNewWindow -Wait Start-Process -FilePath winget -ArgumentList "uninstall -e --purge --force --silent $Program" -NoNewWindow -Wait
@ -580,7 +580,6 @@ function Install-WinUtilWinget {
if (Test-WinUtilPackageManager -winget) { if (Test-WinUtilPackageManager -winget) {
# Checks if winget executable exists and if the Windows Version is 1809 or higher # Checks if winget executable exists and if the Windows Version is 1809 or higher
Write-Host "Winget Already Installed" Write-Host "Winget Already Installed"
Start-Process -Verb runas -FilePath powershell.exe -ArgumentList "winget settings --enable InstallerHashOverride" -Wait -NoNewWindow
return return
} }
@ -598,17 +597,10 @@ function Install-WinUtilWinget {
return return
} }
Write-Host "Running Alternative Installers and Direct Installing" Write-Host "Running Alternative Installer and Direct Installing"
# Checks if winget is installed via Chocolatey Start-Process -Verb runas -FilePath powershell.exe -ArgumentList "choco install winget"
Start-Process -Verb runas -FilePath powershell.exe -ArgumentList "choco install winget --force" -Wait -NoNewWindow Write-Host "Winget Installed"
if (Test-WinUtilPackageManager -winget) {
# Checks if winget executable exists and if the Windows Version is 1809 or higher
Write-Host "Winget Installed via Chocolatey"
return
} else {
Write-Host "- Failed to install Winget via Chocolatey"
}
} }
Catch{ Catch{
throw [WingetFailedInstall]::new('Failed to install') throw [WingetFailedInstall]::new('Failed to install')
@ -2883,7 +2875,7 @@ function Invoke-WPFGetInstalled {
return return
} }
if(!(Test-WinUtilPackageManager -winget) -and $checkbox -eq "winget"){ if(!(Get-Command -Name winget -ErrorAction SilentlyContinue) -and $checkbox -eq "winget"){
Write-Host "===========================================" Write-Host "==========================================="
Write-Host "-- Winget is not installed ---" Write-Host "-- Winget is not installed ---"
Write-Host "===========================================" Write-Host "==========================================="
@ -3217,7 +3209,7 @@ function Invoke-WPFInstall {
} }
Catch { Catch {
Write-Host "===========================================" Write-Host "==========================================="
Write-Host "-- Winget failed to install ---" Write-Host "Error: $_"
Write-Host "===========================================" Write-Host "==========================================="
} }
Start-Sleep -Seconds 5 Start-Sleep -Seconds 5
@ -3231,7 +3223,7 @@ function Invoke-WPFInstallUpgrade {
Invokes the function that upgrades all installed programs using winget Invokes the function that upgrades all installed programs using winget
#> #>
if(!(Test-WinUtilPackageManager -winget)){ if(!(Get-Command -Name winget -ErrorAction SilentlyContinue)){
Write-Host "===========================================" Write-Host "==========================================="
Write-Host "-- Winget is not installed ---" Write-Host "-- Winget is not installed ---"
Write-Host "===========================================" Write-Host "==========================================="