mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2025-07-06 05:03:52 -05:00
Compare commits
4 Commits
24.10.01
...
29c9559a71
Author | SHA1 | Date | |
---|---|---|---|
29c9559a71 | |||
db0024b7c5 | |||
ea60dac8dd | |||
d7405d85c4 |
1
.gitignore
vendored
1
.gitignore
vendored
@ -44,3 +44,4 @@ Microsoft.PowerShell.ConsoleHost.dll
|
||||
microwin.log
|
||||
True
|
||||
test.ps1
|
||||
winutil.ps1
|
||||
|
@ -34,26 +34,34 @@ Function Install-WinUtilProgramWinget {
|
||||
# This is up to the individual package maintainers to enable these options. Aka. not as clean as Linux Package Managers.
|
||||
try {
|
||||
$status = $(Start-Process -FilePath "winget" -ArgumentList "install --id $Program --silent --accept-source-agreements --accept-package-agreements" -Wait -PassThru).ExitCode
|
||||
if($status -ne 0){
|
||||
Write-Host "Attempt with User scope"
|
||||
$status = $(Start-Process -FilePath "winget" -ArgumentList "install --id $Program --scope user --silent --accept-source-agreements --accept-package-agreements" -Wait -PassThru).ExitCode
|
||||
if($status -ne 0){
|
||||
Write-Host "Attempt with Unelevated prompt"
|
||||
$status = $(Start-Process -FilePath "powershell" -ArgumentList "-Command Start-Process winget -ArgumentList 'install --id $Program --silent --accept-source-agreements --accept-package-agreements' -Verb runAsUser" -Wait -PassThru).ExitCode
|
||||
if($status -ne 0){
|
||||
Write-Host "Failed to install $Program."
|
||||
} else {
|
||||
Write-Host "$Program installed successfully with Unelevated prompt."
|
||||
}
|
||||
} else {
|
||||
Write-Host "$Program installed successfully with User scope."
|
||||
}
|
||||
} else {
|
||||
if($status -eq 0){
|
||||
Write-Host "$Program installed successfully."
|
||||
continue
|
||||
}
|
||||
} catch {
|
||||
Write-Host "Attempt with User scope"
|
||||
$status = $(Start-Process -FilePath "winget" -ArgumentList "install --id $Program --scope user --silent --accept-source-agreements --accept-package-agreements" -Wait -PassThru).ExitCode
|
||||
if($status -eq 0){
|
||||
Write-Host "$Program installed successfully with User scope."
|
||||
continue
|
||||
}
|
||||
Write-Host "Attempt with Unelevated prompt"
|
||||
$process = Start-Process -FilePath "powershell" -ArgumentList "-Command Start-Process winget -ArgumentList 'install --id $Program --silent --accept-source-agreements --accept-package-agreements' -Verb runAsUser" -Wait -PassThru
|
||||
if($process.ExitCode -eq 0){
|
||||
Write-Host "$Program installed successfully with Unelevated prompt."
|
||||
continue
|
||||
}
|
||||
Write-Host "Attempting installation with Chocolatey as a fallback method"
|
||||
$chocoStatus = $(Start-Process -FilePath "choco" -ArgumentList "install $Program -y" -Wait -PassThru).ExitCode
|
||||
if($chocoStatus -eq 0){
|
||||
Write-Host "$Program installed successfully using Chocolatey."
|
||||
continue
|
||||
} else {
|
||||
Write-Host "Failed to install $Program using Chocolatey."
|
||||
}
|
||||
Write-Host "Failed to install $Program."
|
||||
} catch {
|
||||
Write-Host "Failed to install $Program due to an error: $_"
|
||||
}
|
||||
}
|
||||
}
|
||||
if($manage -eq "Uninstalling"){
|
||||
# Uninstall package via ID using winget directly.
|
||||
|
46
winutil.ps1
46
winutil.ps1
@ -10,7 +10,7 @@
|
||||
Author : Chris Titus @christitustech
|
||||
Runspace Author: @DeveloperDurp
|
||||
GitHub : https://github.com/ChrisTitusTech
|
||||
Version : 24.04.21
|
||||
Version : 24.05.09
|
||||
#>
|
||||
param (
|
||||
[switch]$Debug,
|
||||
@ -47,7 +47,7 @@ Add-Type -AssemblyName System.Windows.Forms
|
||||
# Variable to sync between runspaces
|
||||
$sync = [Hashtable]::Synchronized(@{})
|
||||
$sync.PSScriptRoot = $PSScriptRoot
|
||||
$sync.version = "24.04.21"
|
||||
$sync.version = "24.05.09"
|
||||
$sync.configs = @{}
|
||||
$sync.ProcessRunning = $false
|
||||
|
||||
@ -733,26 +733,34 @@ Function Install-WinUtilProgramWinget {
|
||||
# This is up to the individual package maintainers to enable these options. Aka. not as clean as Linux Package Managers.
|
||||
try {
|
||||
$status = $(Start-Process -FilePath "winget" -ArgumentList "install --id $Program --silent --accept-source-agreements --accept-package-agreements" -Wait -PassThru).ExitCode
|
||||
if($status -ne 0){
|
||||
Write-Host "Attempt with User scope"
|
||||
$status = $(Start-Process -FilePath "winget" -ArgumentList "install --id $Program --scope user --silent --accept-source-agreements --accept-package-agreements" -Wait -PassThru).ExitCode
|
||||
if($status -ne 0){
|
||||
Write-Host "Attempt with Unelevated prompt"
|
||||
$status = $(Start-Process -FilePath "powershell" -ArgumentList "-Command Start-Process winget -ArgumentList 'install --id $Program --silent --accept-source-agreements --accept-package-agreements' -Verb runAsUser" -Wait -PassThru).ExitCode
|
||||
if($status -ne 0){
|
||||
Write-Host "Failed to install $Program."
|
||||
} else {
|
||||
Write-Host "$Program installed successfully with Unelevated prompt."
|
||||
}
|
||||
} else {
|
||||
Write-Host "$Program installed successfully with User scope."
|
||||
}
|
||||
} else {
|
||||
if($status -eq 0){
|
||||
Write-Host "$Program installed successfully."
|
||||
continue
|
||||
}
|
||||
} catch {
|
||||
Write-Host "Attempt with User scope"
|
||||
$status = $(Start-Process -FilePath "winget" -ArgumentList "install --id $Program --scope user --silent --accept-source-agreements --accept-package-agreements" -Wait -PassThru).ExitCode
|
||||
if($status -eq 0){
|
||||
Write-Host "$Program installed successfully with User scope."
|
||||
continue
|
||||
}
|
||||
Write-Host "Attempt with Unelevated prompt"
|
||||
$process = Start-Process -FilePath "powershell" -ArgumentList "-Command Start-Process winget -ArgumentList 'install --id $Program --silent --accept-source-agreements --accept-package-agreements' -Verb runAsUser" -Wait -PassThru
|
||||
if($process.ExitCode -eq 0){
|
||||
Write-Host "$Program installed successfully with Unelevated prompt."
|
||||
continue
|
||||
}
|
||||
Write-Host "Attempting installation with Chocolatey as a fallback method"
|
||||
$chocoStatus = $(Start-Process -FilePath "choco" -ArgumentList "install $Program -y" -Wait -PassThru).ExitCode
|
||||
if($chocoStatus -eq 0){
|
||||
Write-Host "$Program installed successfully using Chocolatey."
|
||||
continue
|
||||
} else {
|
||||
Write-Host "Failed to install $Program using Chocolatey."
|
||||
}
|
||||
Write-Host "Failed to install $Program."
|
||||
} catch {
|
||||
Write-Host "Failed to install $Program due to an error: $_"
|
||||
}
|
||||
}
|
||||
}
|
||||
if($manage -eq "Uninstalling"){
|
||||
# Uninstall package via ID using winget directly.
|
||||
|
Reference in New Issue
Block a user