mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2025-07-01 10:32:35 -05:00
Compare commits
4 Commits
27a97e4650
...
25.03.04
Author | SHA1 | Date | |
---|---|---|---|
18a7f17a0b | |||
5a8cf5deb6 | |||
e4b2a38372 | |||
94c5d89430 |
6
.github/ISSUE_TEMPLATE/bug_report.yaml
vendored
6
.github/ISSUE_TEMPLATE/bug_report.yaml
vendored
@ -7,10 +7,10 @@ body:
|
||||
attributes:
|
||||
value: |
|
||||
# 🐞 **Issue Report**
|
||||
Thank you for taking the time to report an issue! Please provide as much detail as possible to help us address the problem efficiently.
|
||||
Thank you for taking the time to report an issue! Please provide as much detail as possible to help us address the problem efficiently.
|
||||
|
||||
## ⚠️ **IMPORTANT**
|
||||
- 🛠️ **Supported environments only:** We only support Windows 11. Custom ISOs that are not made using Microwin are not supported.
|
||||
## ⚠️ **IMPORTANT**
|
||||
- 🛠️ **Supported environments only:** We only support Windows 11. Custom ISOs that are not made using Microwin are not supported.
|
||||
- 💡 For general questions, use the [Discussions section](https://github.com/Christitustech/winutil/discussions) or join our Community-driven [Discord Server](https://discord.gg/RUbZUZyByQ).
|
||||
|
||||
- type: checkboxes
|
||||
|
4
.github/ISSUE_TEMPLATE/feature_request.yaml
vendored
4
.github/ISSUE_TEMPLATE/feature_request.yaml
vendored
@ -9,7 +9,7 @@ body:
|
||||
# ✨ **Feature request**
|
||||
Thank you for taking the time to suggest a feature! Please provide as much detail as possible to help us understand and evaluate your request.
|
||||
|
||||
## ⚠️ **IMPORTANT**
|
||||
## ⚠️ **IMPORTANT**
|
||||
- 🛠️ **Supported environments only:** We only support Windows 11.
|
||||
- 💡 For general questions, use the [Discussions section](https://github.com/Christitustech/winutil/discussions) or join our Community-driven [Discord Server](https://discord.gg/RUbZUZyByQ).
|
||||
|
||||
@ -54,4 +54,4 @@ body:
|
||||
label: 🖼️ Additional context
|
||||
placeholder: "Include screenshots, code blocks (use triple backticks ```), or any other relevant information."
|
||||
validations:
|
||||
required: false
|
||||
required: false
|
||||
|
@ -1,5 +1,6 @@
|
||||
# Import the function (adjust the path according to your setup)
|
||||
. "./functions/private/Get-WinUtilWingetLatest.ps1"
|
||||
. "./functions/private/Install-WinUtilWinget.ps1"
|
||||
. "./functions/private/Test-WinUtilPackageManager.ps1"
|
||||
|
||||
# Set up Information stream to be visible
|
||||
$InformationPreference = "Continue"
|
||||
@ -7,20 +8,7 @@ $InformationPreference = "Continue"
|
||||
Write-Host "Starting Winget installation test..." -ForegroundColor Cyan
|
||||
|
||||
try {
|
||||
# Test the function with verbose output
|
||||
Write-Host "Attempting to run Get-WinUtilWingetLatest..." -ForegroundColor Cyan
|
||||
Get-WinUtilWingetLatest -Verbose
|
||||
|
||||
# Verify Winget is working
|
||||
if (Get-Command winget -ErrorAction SilentlyContinue) {
|
||||
Write-Host "Success! Winget is installed and accessible." -ForegroundColor Green
|
||||
|
||||
# Display Winget version
|
||||
Write-Host "`nWinget version:" -ForegroundColor Cyan
|
||||
winget --version
|
||||
} else {
|
||||
Write-Host "Warning: Winget is installed but not accessible in the current session. You may need to restart your terminal." -ForegroundColor Yellow
|
||||
}
|
||||
Install-WinUtilWinget
|
||||
} catch {
|
||||
Write-Host "Error occurred during testing: $($_.Exception.Message)" -ForegroundColor Red
|
||||
Write-Host "Stack Trace:" -ForegroundColor Red
|
||||
|
@ -2934,5 +2934,13 @@
|
||||
"description": "Fork - a fast and friendly git client.",
|
||||
"link": "https://git-fork.com/",
|
||||
"winget": "Fork.Fork"
|
||||
},
|
||||
"ZenBrowser": {
|
||||
"category": "Browsers",
|
||||
"choco": "na",
|
||||
"content": "Zen Browser",
|
||||
"description": "The modern, privacy-focused, performance-driven browser built on Firefox",
|
||||
"link": "https://zen-browser.app/",
|
||||
"winget": "Zen-Team.Zen-Browser"
|
||||
}
|
||||
}
|
||||
|
@ -423,26 +423,6 @@
|
||||
"StartupType": "Automatic",
|
||||
"OriginalType": "Automatic"
|
||||
},
|
||||
{
|
||||
"Name": "DoSvc",
|
||||
"StartupType": "AutomaticDelayedStart",
|
||||
"OriginalType": "Automatic"
|
||||
},
|
||||
{
|
||||
"Name": "DsSvc",
|
||||
"StartupType": "Manual",
|
||||
"OriginalType": "Manual"
|
||||
},
|
||||
{
|
||||
"Name": "DsmSvc",
|
||||
"StartupType": "Manual",
|
||||
"OriginalType": "Manual"
|
||||
},
|
||||
{
|
||||
"Name": "DusmSvc",
|
||||
"StartupType": "Automatic",
|
||||
"OriginalType": "Automatic"
|
||||
},
|
||||
{
|
||||
"Name": "EFS",
|
||||
"StartupType": "Manual",
|
||||
@ -898,11 +878,6 @@
|
||||
"StartupType": "Manual",
|
||||
"OriginalType": "Manual"
|
||||
},
|
||||
{
|
||||
"Name": "SgrmBroker",
|
||||
"StartupType": "Automatic",
|
||||
"OriginalType": "Automatic"
|
||||
},
|
||||
{
|
||||
"Name": "SharedAccess",
|
||||
"StartupType": "Manual",
|
||||
@ -933,11 +908,6 @@
|
||||
"StartupType": "Manual",
|
||||
"OriginalType": "Manual"
|
||||
},
|
||||
{
|
||||
"Name": "StateRepository",
|
||||
"StartupType": "Manual",
|
||||
"OriginalType": "Automatic"
|
||||
},
|
||||
{
|
||||
"Name": "StiSvc",
|
||||
"StartupType": "Manual",
|
||||
@ -973,11 +943,6 @@
|
||||
"StartupType": "Automatic",
|
||||
"OriginalType": "Automatic"
|
||||
},
|
||||
{
|
||||
"Name": "TextInputManagementService",
|
||||
"StartupType": "Manual",
|
||||
"OriginalType": "Automatic"
|
||||
},
|
||||
{
|
||||
"Name": "Themes",
|
||||
"StartupType": "Automatic",
|
||||
|
@ -1,104 +0,0 @@
|
||||
function Get-WinUtilWingetLatest {
|
||||
[CmdletBinding()]
|
||||
param()
|
||||
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Uses GitHub API to check for the latest release of Winget.
|
||||
.DESCRIPTION
|
||||
This function first attempts to update WinGet using winget itself, then falls back to manual installation if needed.
|
||||
#>
|
||||
$ProgressPreference = "SilentlyContinue"
|
||||
$InformationPreference = 'Continue'
|
||||
|
||||
try {
|
||||
$wingetCmd = Get-Command winget -ErrorAction Stop
|
||||
Write-Information "Attempting to update WinGet using WinGet..."
|
||||
$result = Start-Process -FilePath "`"$($wingetCmd.Source)`"" -ArgumentList "install -e --accept-source-agreements --accept-package-agreements Microsoft.AppInstaller" -Wait -NoNewWindow -PassThru
|
||||
if ($result.ExitCode -ne 0) {
|
||||
throw "WinGet update failed with exit code: $($result.ExitCode)"
|
||||
}
|
||||
return $true
|
||||
}
|
||||
catch {
|
||||
Write-Information "WinGet not found or update failed. Attempting to install from Microsoft Store..."
|
||||
try {
|
||||
# Try to close any running WinGet processes
|
||||
Get-Process -Name "DesktopAppInstaller", "winget" -ErrorAction SilentlyContinue | ForEach-Object {
|
||||
Write-Information "Stopping running WinGet process..."
|
||||
$_.Kill()
|
||||
Start-Sleep -Seconds 2
|
||||
}
|
||||
|
||||
# Try to load Windows Runtime assemblies more reliably
|
||||
$null = [System.Runtime.WindowsRuntime.WindowsRuntimeSystemExtensions]
|
||||
Add-Type -AssemblyName System.Runtime.WindowsRuntime
|
||||
|
||||
# Load required assemblies from Windows SDK
|
||||
$null = @(
|
||||
[Windows.Management.Deployment.PackageManager, Windows.Management.Deployment, ContentType = WindowsRuntime]
|
||||
[Windows.Foundation.Uri, Windows.Foundation, ContentType = WindowsRuntime]
|
||||
[Windows.Management.Deployment.DeploymentOptions, Windows.Management.Deployment, ContentType = WindowsRuntime]
|
||||
)
|
||||
|
||||
# Initialize PackageManager
|
||||
$packageManager = New-Object Windows.Management.Deployment.PackageManager
|
||||
|
||||
# Rest of the Microsoft Store installation logic
|
||||
$appxPackage = "https://aka.ms/getwinget"
|
||||
$uri = New-Object Windows.Foundation.Uri($appxPackage)
|
||||
$deploymentOperation = $packageManager.AddPackageAsync($uri, $null, "Add")
|
||||
|
||||
# Add timeout check for deployment operation
|
||||
$timeout = 300
|
||||
$timer = [System.Diagnostics.Stopwatch]::StartNew()
|
||||
|
||||
while ($deploymentOperation.Status -eq 0) {
|
||||
if ($timer.Elapsed.TotalSeconds -gt $timeout) {
|
||||
throw "Installation timed out after $timeout seconds"
|
||||
}
|
||||
Start-Sleep -Milliseconds 100
|
||||
}
|
||||
|
||||
if ($deploymentOperation.Status -eq 1) {
|
||||
Write-Information "Successfully installed WinGet from Microsoft Store"
|
||||
return $true
|
||||
} else {
|
||||
throw "Installation failed with status: $($deploymentOperation.Status)"
|
||||
}
|
||||
}
|
||||
catch [System.Management.Automation.RuntimeException] {
|
||||
Write-Information "Windows Runtime components not available. Attempting manual download..."
|
||||
try {
|
||||
# Try to close any running WinGet processes
|
||||
Get-Process -Name "DesktopAppInstaller", "winget" -ErrorAction SilentlyContinue | ForEach-Object {
|
||||
Write-Information "Stopping running WinGet process..."
|
||||
$_.Kill()
|
||||
Start-Sleep -Seconds 2
|
||||
}
|
||||
|
||||
# Fallback to direct download from GitHub
|
||||
$apiUrl = "https://api.github.com/repos/microsoft/winget-cli/releases/latest"
|
||||
$release = Invoke-RestMethod -Uri $apiUrl
|
||||
$msixBundleUrl = ($release.assets | Where-Object { $_.name -like "*.msixbundle" }).browser_download_url
|
||||
|
||||
$tempFile = Join-Path $env:TEMP "Microsoft.DesktopAppInstaller.msixbundle"
|
||||
Invoke-WebRequest -Uri $msixBundleUrl -OutFile $tempFile
|
||||
|
||||
Add-AppxPackage -Path $tempFile -ErrorAction Stop
|
||||
Remove-Item $tempFile -Force
|
||||
|
||||
Write-Information "Successfully installed WinGet from GitHub release"
|
||||
return $true
|
||||
}
|
||||
catch {
|
||||
Write-Error "Failed to install WinGet: $_"
|
||||
return $false
|
||||
}
|
||||
}
|
||||
catch {
|
||||
Write-Error "Failed to install WinGet: $_"
|
||||
return $false
|
||||
}
|
||||
}
|
||||
}
|
@ -33,18 +33,44 @@ function Install-WinUtilWinget {
|
||||
return
|
||||
}
|
||||
|
||||
# Install Winget via GitHub method.
|
||||
# Used part of my own script with some modification: ruxunderscore/windows-initialization
|
||||
Write-Host "Downloading Winget and License File`r"
|
||||
Get-WinUtilWingetLatest
|
||||
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-Error "Failed to install Winget: $($_.Exception.Message)"
|
||||
}
|
||||
Write-Host "Attempting to install/update Winget`r"
|
||||
try {
|
||||
$wingetCmd = Get-Command winget -ErrorAction Stop
|
||||
Write-Information "Attempting to update WinGet using WinGet..."
|
||||
$result = Start-Process -FilePath "`"$($wingetCmd.Source)`"" -ArgumentList "install -e --accept-source-agreements --accept-package-agreements Microsoft.AppInstaller" -Wait -NoNewWindow -PassThru
|
||||
if ($result.ExitCode -ne 0) {
|
||||
throw "WinGet update failed with exit code: $($result.ExitCode)"
|
||||
}
|
||||
Write-Output "Refreshing Environment Variables...`n"
|
||||
$ENV:PATH = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "User")
|
||||
return
|
||||
} catch {
|
||||
Write-Information "WinGet not found or update failed. Attempting to install from Microsoft Store..."
|
||||
}
|
||||
try {
|
||||
Write-Host "Attempting to repair WinGet using Repair-WinGetPackageManager..." -ForegroundColor Yellow
|
||||
|
||||
# Check if Windows version supports Repair-WinGetPackageManager (24H2 and above)
|
||||
if ([System.Environment]::OSVersion.Version.Build -ge 26100) {
|
||||
Repair-WinGetPackageManager -Force -Latest -Verbose
|
||||
# Verify if repair was successful
|
||||
$wingetCmd = Get-Command winget -ErrorAction Stop
|
||||
Write-Host "WinGet repair successful!" -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host "Repair-WinGetPackageManager is only available on Windows 24H2 and above. Your version doesn't support this method." -ForegroundColor Yellow
|
||||
throw "Windows version not supported for repair method"
|
||||
}
|
||||
|
||||
Write-Output "Refreshing Environment Variables...`n"
|
||||
$ENV:PATH = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "User")
|
||||
return
|
||||
|
||||
} catch {
|
||||
Write-Error "All installation methods failed. Unable to install WinGet."
|
||||
throw
|
||||
}
|
||||
} catch {
|
||||
Write-Error "An error occurred during WinGet installation: $_"
|
||||
throw
|
||||
}
|
||||
}
|
||||
|
@ -23,14 +23,22 @@ function Test-WinUtilPackageManager {
|
||||
# Check if Winget is available while getting it's Version if it's available
|
||||
$wingetExists = $true
|
||||
try {
|
||||
$wingetVersionFull = winget --version
|
||||
$wingetInfo = winget --info
|
||||
# Extract the package version from the output
|
||||
$wingetVersionFull = ($wingetInfo | Select-String -Pattern 'Microsoft\.DesktopAppInstaller v\d+\.\d+\.\d+\.\d+').Matches.Value
|
||||
if ($wingetVersionFull) {
|
||||
$wingetVersionFull = $wingetVersionFull.Split(' ')[-1].TrimStart('v')
|
||||
} else {
|
||||
# Fallback in case the pattern isn't found
|
||||
$wingetVersionFull = ($wingetInfo | Select-String -Pattern 'Package Manager v\d+\.\d+\.\d+').Matches.Value.Split(' ')[-1]
|
||||
}
|
||||
} catch [System.Management.Automation.CommandNotFoundException], [System.Management.Automation.ApplicationFailedException] {
|
||||
Write-Warning "Winget was not found due to un-availablity reasons"
|
||||
$wingetExists = $false
|
||||
} catch {
|
||||
Write-Warning "Winget was not found due to un-known reasons, The Stack Trace is:`n$($psitem.Exception.StackTrace)"
|
||||
$wingetExists = $false
|
||||
}
|
||||
}
|
||||
|
||||
# If Winget is available, Parse it's Version and give proper information to Terminal Output.
|
||||
# If it isn't available, the return of this funtion will be "not-installed", indicating that
|
||||
@ -48,13 +56,14 @@ function Test-WinUtilPackageManager {
|
||||
# Check if Winget's Version is too old.
|
||||
$wingetCurrentVersion = [System.Version]::Parse($wingetVersion.Trim('v'))
|
||||
# Grabs the latest release of Winget from the Github API for version check process.
|
||||
$response = Invoke-RestMethod -Uri "https://api.github.com/repos/microsoft/Winget-cli/releases/latest" -Method Get -ErrorAction Stop
|
||||
$wingetLatestVersion = [System.Version]::Parse(($response.tag_name).Trim('v')) #Stores version number of latest release.
|
||||
$wingetOutdated = $wingetCurrentVersion -lt $wingetLatestVersion
|
||||
$response = winget search -e Microsoft.AppInstaller
|
||||
$wingetLatestVersion = ($response | Select-String -Pattern '\d+\.\d+\.\d+\.\d+').Matches.Value
|
||||
Write-Host "Latest Search Version: $wingetLatestVersion" -ForegroundColor White
|
||||
Write-Host "Current Installed Version: $wingetCurrentVersion" -ForegroundColor White
|
||||
$wingetOutdated = $wingetCurrentVersion -lt [System.Version]::Parse($wingetLatestVersion)
|
||||
Write-Host "===========================================" -ForegroundColor Green
|
||||
Write-Host "--- Winget is installed ---" -ForegroundColor Green
|
||||
Write-Host "===========================================" -ForegroundColor Green
|
||||
Write-Host "Version: $wingetVersionFull" -ForegroundColor White
|
||||
|
||||
if (!$wingetPreview) {
|
||||
Write-Host " - Winget is a release version." -ForegroundColor Green
|
||||
|
Reference in New Issue
Block a user