mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2024-11-14 22:55:52 -06:00
1032d3d5aa
* Add Progress bar to some stuff https://learn.microsoft.com/en-us/dotnet/api/system.windows.shell.taskbariteminfo?view=windowsdesktop-8.0 * add function to manage taskbar item changed from manually setting the taskbar overlay, progressvalue and progress state to setting them through a function * add description feature * use Dispatcher.Invoke * restructure, fix, additions * fix merge conflicts * add check to progresses * remove progress from wiget & choco install * fix * polish * fix * Update functions/private/Set-WinUtilTaskbarItem.ps1 Co-authored-by: Mr.k <mineshtine28546271@gmail.com> * fix syntax * Update functions/private/Set-WinUtilTaskbarItem.ps1 Co-authored-by: Mr.k <mineshtine28546271@gmail.com> * rework - add overlay presets - rework image saving & converting - removed popup after uninstalling applications * fix description of function * undo winutil * remove check.png * Update functions/private/Set-WinUtilTaskbarItem.ps1 Co-authored-by: Mr.k <mineshtine28546271@gmail.com> * Update functions/private/Set-WinUtilTaskbarItem.ps1 Co-authored-by: Mr.k <mineshtine28546271@gmail.com> * rework assets directory & its usage * fixes - ability to set no overlay added - added relative path to winutildir * hotfix * last fixes * add comment * remove trailing whitespaces THX to Mr.K :) * renamed checkmark & added warning * last fixes remove bitmap remove unneeded "| out-null" * hotfix for new commit --------- Co-authored-by: Mr.k <mineshtine28546271@gmail.com>
69 lines
3.3 KiB
PowerShell
69 lines
3.3 KiB
PowerShell
function Install-WinUtilWinget {
|
|
<#
|
|
|
|
.SYNOPSIS
|
|
Installs Winget if it is not already installed.
|
|
|
|
.DESCRIPTION
|
|
This function will download the latest version of Winget and install it. If Winget is already installed, it will do nothing.
|
|
#>
|
|
$isWingetInstalled = Test-WinUtilPackageManager -winget
|
|
|
|
Try {
|
|
if ($isWingetInstalled -eq "installed") {
|
|
Write-Host "`nWinget is already installed.`r" -ForegroundColor Green
|
|
return
|
|
} elseif ($isWingetInstalled -eq "outdated") {
|
|
Write-Host "`nWinget is Outdated. Continuing with install.`r" -ForegroundColor Yellow
|
|
} else {
|
|
Write-Host "`nWinget is not Installed. Continuing with install.`r" -ForegroundColor Red
|
|
}
|
|
|
|
|
|
# Gets the computer's information
|
|
if ($null -eq $sync.ComputerInfo){
|
|
$ComputerInfo = Get-ComputerInfo -ErrorAction Stop
|
|
} else {
|
|
$ComputerInfo = $sync.ComputerInfo
|
|
}
|
|
|
|
if (($ComputerInfo.WindowsVersion) -lt "1809") {
|
|
# Checks if Windows Version is too old for Winget
|
|
Write-Host "Winget is not supported on this version of Windows (Pre-1809)" -ForegroundColor Red
|
|
return
|
|
}
|
|
|
|
# Install Winget via GitHub method.
|
|
# Used part of my own script with some modification: ruxunderscore/windows-initialization
|
|
Write-Host "Downloading Winget Prerequsites`n"
|
|
Get-WinUtilWingetPrerequisites
|
|
Write-Host "Downloading Winget and License File`r"
|
|
Get-WinUtilWingetLatest
|
|
Write-Host "Installing Winget w/ Prerequsites`r"
|
|
Add-AppxProvisionedPackage -Online -PackagePath $ENV:TEMP\Microsoft.DesktopAppInstaller.msixbundle -DependencyPackagePath $ENV:TEMP\Microsoft.VCLibs.x64.Desktop.appx, $ENV:TEMP\Microsoft.UI.Xaml.x64.appx -LicensePath $ENV:TEMP\License1.xml
|
|
Write-Host "Manually adding Winget Sources, from Winget CDN."
|
|
Add-AppxPackage -Path https://cdn.winget.microsoft.com/cache/source.msix #Seems some installs of Winget don't add the repo source, this should makes sure that it's installed every time.
|
|
Write-Host "Winget Installed" -ForegroundColor Green
|
|
Write-Host "Enabling NuGet and Module..."
|
|
Install-PackageProvider -Name NuGet -Force
|
|
Install-Module -Name Microsoft.WinGet.Client -Force
|
|
# Winget only needs a refresh of the environment variables to be used.
|
|
Write-Output "Refreshing Environment Variables...`n"
|
|
$ENV:PATH = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "User")
|
|
} Catch {
|
|
Write-Host "Failure detected while installing via GitHub method. Continuing with Chocolatey method as fallback." -ForegroundColor Red
|
|
# In case install fails via GitHub method.
|
|
Try {
|
|
# Install Choco if not already present
|
|
Install-WinUtilChoco
|
|
Start-Process -Verb runas -FilePath powershell.exe -ArgumentList "choco install winget-cli"
|
|
Write-Host "Winget Installed" -ForegroundColor Green
|
|
Write-Output "Refreshing Environment Variables...`n"
|
|
$ENV:PATH = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "User")
|
|
} Catch {
|
|
throw [WingetFailedInstall]::new('Failed to install!')
|
|
}
|
|
}
|
|
|
|
}
|