mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2025-07-06 13:13:50 -05:00
Compare commits
4 Commits
revert-329
...
29c9559a71
Author | SHA1 | Date | |
---|---|---|---|
29c9559a71 | |||
db0024b7c5 | |||
ea60dac8dd | |||
d7405d85c4 |
1
.gitignore
vendored
1
.gitignore
vendored
@ -44,3 +44,4 @@ Microsoft.PowerShell.ConsoleHost.dll
|
|||||||
microwin.log
|
microwin.log
|
||||||
True
|
True
|
||||||
test.ps1
|
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.
|
# This is up to the individual package maintainers to enable these options. Aka. not as clean as Linux Package Managers.
|
||||||
try {
|
try {
|
||||||
$status = $(Start-Process -FilePath "winget" -ArgumentList "install --id $Program --silent --accept-source-agreements --accept-package-agreements" -Wait -PassThru).ExitCode
|
$status = $(Start-Process -FilePath "winget" -ArgumentList "install --id $Program --silent --accept-source-agreements --accept-package-agreements" -Wait -PassThru).ExitCode
|
||||||
if($status -ne 0){
|
if($status -eq 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 {
|
|
||||||
Write-Host "$Program installed successfully."
|
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: $_"
|
Write-Host "Failed to install $Program due to an error: $_"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if($manage -eq "Uninstalling"){
|
if($manage -eq "Uninstalling"){
|
||||||
# Uninstall package via ID using winget directly.
|
# Uninstall package via ID using winget directly.
|
||||||
|
46
winutil.ps1
46
winutil.ps1
@ -10,7 +10,7 @@
|
|||||||
Author : Chris Titus @christitustech
|
Author : Chris Titus @christitustech
|
||||||
Runspace Author: @DeveloperDurp
|
Runspace Author: @DeveloperDurp
|
||||||
GitHub : https://github.com/ChrisTitusTech
|
GitHub : https://github.com/ChrisTitusTech
|
||||||
Version : 24.04.21
|
Version : 24.05.09
|
||||||
#>
|
#>
|
||||||
param (
|
param (
|
||||||
[switch]$Debug,
|
[switch]$Debug,
|
||||||
@ -47,7 +47,7 @@ Add-Type -AssemblyName System.Windows.Forms
|
|||||||
# Variable to sync between runspaces
|
# Variable to sync between runspaces
|
||||||
$sync = [Hashtable]::Synchronized(@{})
|
$sync = [Hashtable]::Synchronized(@{})
|
||||||
$sync.PSScriptRoot = $PSScriptRoot
|
$sync.PSScriptRoot = $PSScriptRoot
|
||||||
$sync.version = "24.04.21"
|
$sync.version = "24.05.09"
|
||||||
$sync.configs = @{}
|
$sync.configs = @{}
|
||||||
$sync.ProcessRunning = $false
|
$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.
|
# This is up to the individual package maintainers to enable these options. Aka. not as clean as Linux Package Managers.
|
||||||
try {
|
try {
|
||||||
$status = $(Start-Process -FilePath "winget" -ArgumentList "install --id $Program --silent --accept-source-agreements --accept-package-agreements" -Wait -PassThru).ExitCode
|
$status = $(Start-Process -FilePath "winget" -ArgumentList "install --id $Program --silent --accept-source-agreements --accept-package-agreements" -Wait -PassThru).ExitCode
|
||||||
if($status -ne 0){
|
if($status -eq 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 {
|
|
||||||
Write-Host "$Program installed successfully."
|
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: $_"
|
Write-Host "Failed to install $Program due to an error: $_"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if($manage -eq "Uninstalling"){
|
if($manage -eq "Uninstalling"){
|
||||||
# Uninstall package via ID using winget directly.
|
# Uninstall package via ID using winget directly.
|
||||||
|
Reference in New Issue
Block a user