mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2025-01-16 01:40:35 -06:00
Compare commits
No commits in common. "0ba0e348e597f7e3169a4995de16e445c6b0a431" and "7f482d5e4be09eceb1684a97b5de147d749a4d61" have entirely different histories.
0ba0e348e5
...
7f482d5e4b
Binary file not shown.
Before Width: | Height: | Size: 213 KiB After Width: | Height: | Size: 152 KiB |
@ -69,7 +69,7 @@ function Invoke-WPFTweakPS7{
|
|||||||
Write-Host "Powershell 7 is already installed."
|
Write-Host "Powershell 7 is already installed."
|
||||||
} else {
|
} else {
|
||||||
Write-Host "Installing Powershell 7..."
|
Write-Host "Installing Powershell 7..."
|
||||||
Install-WinUtilProgramWinget -Action Install -Programs @("Microsoft.PowerShell")
|
Invoke-WinUtilWingetProgram -Action Install -Programs @("Microsoft.PowerShell")
|
||||||
}
|
}
|
||||||
$targetTerminalName = "PowerShell"
|
$targetTerminalName = "PowerShell"
|
||||||
}
|
}
|
||||||
@ -105,10 +105,10 @@ function Invoke-WPFTweakPS7{
|
|||||||
}
|
}
|
||||||
|
|
||||||
```
|
```
|
||||||
## Function: Install-WinUtilProgramWinget
|
## Function: Invoke-WinUtilWingetProgram
|
||||||
|
|
||||||
```powershell
|
```powershell
|
||||||
Function Install-WinUtilProgramWinget {
|
Function Invoke-WinUtilWingetProgram {
|
||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Runs the designated action on the provided programs using Winget
|
Runs the designated action on the provided programs using Winget
|
||||||
|
@ -29,11 +29,6 @@
|
|||||||
* Click the `Clear Selection` button.
|
* Click the `Clear Selection` button.
|
||||||
* This will unselect all checked programs.
|
* This will unselect all checked programs.
|
||||||
|
|
||||||
=== "prefer Chocolatey"
|
|
||||||
* Check the `prefer Chocolatey` checkbox
|
|
||||||
* By default Winutil will use winget to install/upgrade/remove packages and fallback to Chocolatey. This option reverses the preference.
|
|
||||||
* This preference will be used for all Buttons on the Install page and persist across Winutil restarts
|
|
||||||
|
|
||||||
![Install Image](assets/Install-Tab-Dark.png#only-dark)
|
![Install Image](assets/Install-Tab-Dark.png#only-dark)
|
||||||
![Install Image](assets/Install-Tab-Light.png#only-light)
|
![Install Image](assets/Install-Tab-Light.png#only-light)
|
||||||
!!! tip
|
!!! tip
|
||||||
|
@ -1,258 +1,112 @@
|
|||||||
function Install-WinUtilProgramChoco {
|
function Install-WinUtilProgramChoco {
|
||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Manages the installation or uninstallation of a list of Chocolatey packages.
|
Manages the provided programs using Chocolatey
|
||||||
|
|
||||||
.PARAMETER Programs
|
.PARAMETER ProgramsToInstall
|
||||||
A string array containing the programs to be installed or uninstalled.
|
A list of programs to manage
|
||||||
|
|
||||||
.PARAMETER Action
|
.PARAMETER manage
|
||||||
Specifies the action to perform: "Install" or "Uninstall". The default value is "Install".
|
The action to perform on the programs, can be either 'Installing' or 'Uninstalling'
|
||||||
|
|
||||||
.DESCRIPTION
|
.NOTES
|
||||||
This function processes a list of programs to be managed using Chocolatey. Depending on the specified action, it either installs or uninstalls each program in the list, updating the taskbar progress accordingly. After all operations are completed, temporary output files are cleaned up.
|
The triple quotes are required any time you need a " in a normal script block.
|
||||||
|
|
||||||
.EXAMPLE
|
|
||||||
Install-WinUtilProgramChoco -Programs @("7zip","chrome") -Action "Uninstall"
|
|
||||||
#>
|
#>
|
||||||
|
|
||||||
param(
|
param(
|
||||||
[Parameter(Mandatory, Position = 0)]
|
[Parameter(Mandatory, Position = 0)]
|
||||||
[string[]]$Programs,
|
[PsCustomObject]$ProgramsToInstall,
|
||||||
|
|
||||||
[Parameter(Position = 1)]
|
[Parameter(Position = 1)]
|
||||||
[String]$Action = "Install"
|
[String]$manage = "Installing"
|
||||||
)
|
)
|
||||||
|
|
||||||
function Initialize-OutputFile {
|
$x = 0
|
||||||
<#
|
$count = $ProgramsToInstall.Count
|
||||||
.SYNOPSIS
|
|
||||||
Initializes an output file by removing any existing file and creating a new, empty file at the specified path.
|
|
||||||
|
|
||||||
.PARAMETER filePath
|
# This check isn't really necessary, as there's a couple of checks before this Private Function gets called, but just to make sure ;)
|
||||||
The full path to the file to be initialized.
|
if ($count -le 0) {
|
||||||
|
throw "Private Function 'Install-WinUtilProgramChoco' expected Parameter 'ProgramsToInstall' to be of size 1 or greater, instead got $count,`nPlease double check your code and re-compile WinUtil."
|
||||||
.DESCRIPTION
|
|
||||||
This function ensures that the specified file is reset by removing any existing file at the provided path and then creating a new, empty file. It is useful when preparing a log or output file for subsequent operations.
|
|
||||||
|
|
||||||
.EXAMPLE
|
|
||||||
Initialize-OutputFile -filePath "C:\temp\output.txt"
|
|
||||||
#>
|
|
||||||
|
|
||||||
param ($filePath)
|
|
||||||
Remove-Item -Path $filePath -Force -ErrorAction SilentlyContinue
|
|
||||||
New-Item -ItemType File -Path $filePath | Out-Null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function Run-ChocoCommand {
|
|
||||||
<#
|
|
||||||
.SYNOPSIS
|
|
||||||
Executes a Chocolatey command with the specified arguments and returns the exit code.
|
|
||||||
|
|
||||||
.PARAMETER arguments
|
Write-Host "==========================================="
|
||||||
The arguments to be passed to the Chocolatey command.
|
Write-Host "-- Configuring Chocolatey pacakages ---"
|
||||||
|
Write-Host "==========================================="
|
||||||
.DESCRIPTION
|
Foreach ($Program in $ProgramsToInstall) {
|
||||||
This function runs a specified Chocolatey command by passing the provided arguments to the `choco` executable. It waits for the process to complete and then returns the exit code, allowing the caller to determine success or failure based on the exit code.
|
|
||||||
|
|
||||||
.RETURNS
|
|
||||||
[int]
|
|
||||||
The exit code of the Chocolatey command.
|
|
||||||
|
|
||||||
.EXAMPLE
|
|
||||||
$exitCode = Run-ChocoCommand -arguments "install 7zip -y"
|
|
||||||
#>
|
|
||||||
|
|
||||||
param ($arguments)
|
|
||||||
return (Start-Process -FilePath "choco" -ArgumentList $arguments -Wait -PassThru).ExitCode
|
|
||||||
}
|
|
||||||
|
|
||||||
function Check-UpgradeNeeded {
|
|
||||||
<#
|
|
||||||
.SYNOPSIS
|
|
||||||
Checks if an upgrade is needed for a Chocolatey package based on the content of a log file.
|
|
||||||
|
|
||||||
.PARAMETER filePath
|
|
||||||
The path to the log file that contains the output of a Chocolatey install command.
|
|
||||||
|
|
||||||
.DESCRIPTION
|
|
||||||
This function reads the specified log file and checks for keywords that indicate whether an upgrade is needed. It returns a boolean value indicating whether the terms "reinstall" or "already installed" are present, which suggests that the package might need an upgrade.
|
|
||||||
|
|
||||||
.RETURNS
|
|
||||||
[bool]
|
|
||||||
True if the log file indicates that an upgrade is needed; otherwise, false.
|
|
||||||
|
|
||||||
.EXAMPLE
|
|
||||||
$isUpgradeNeeded = Check-UpgradeNeeded -filePath "C:\temp\install-output.txt"
|
|
||||||
#>
|
|
||||||
|
|
||||||
param ($filePath)
|
|
||||||
return Get-Content -Path $filePath | Select-String -Pattern "reinstall|already installed" -Quiet
|
|
||||||
}
|
|
||||||
|
|
||||||
function Update-TaskbarProgress {
|
|
||||||
<#
|
|
||||||
.SYNOPSIS
|
|
||||||
Updates the taskbar progress based on the current installation progress.
|
|
||||||
|
|
||||||
.PARAMETER currentIndex
|
|
||||||
The current index of the program being installed or uninstalled.
|
|
||||||
|
|
||||||
.PARAMETER totalPrograms
|
|
||||||
The total number of programs to be installed or uninstalled.
|
|
||||||
|
|
||||||
.DESCRIPTION
|
|
||||||
This function calculates the progress of the installation or uninstallation process and updates the taskbar accordingly. The taskbar is set to "Normal" if all programs have been processed, otherwise, it is set to "Error" as a placeholder.
|
|
||||||
|
|
||||||
.EXAMPLE
|
|
||||||
Update-TaskbarProgress -currentIndex 3 -totalPrograms 10
|
|
||||||
#>
|
|
||||||
|
|
||||||
param (
|
|
||||||
[int]$currentIndex,
|
|
||||||
[int]$totalPrograms
|
|
||||||
)
|
|
||||||
$progressState = if ($currentIndex -eq $totalPrograms) { "Normal" } else { "Error" }
|
|
||||||
$sync.form.Dispatcher.Invoke([action] { Set-WinUtilTaskbaritem -state $progressState -value ($currentIndex / $totalPrograms) })
|
|
||||||
}
|
|
||||||
|
|
||||||
function Install-ChocoPackage {
|
|
||||||
<#
|
|
||||||
.SYNOPSIS
|
|
||||||
Installs a Chocolatey package and optionally upgrades it if needed.
|
|
||||||
|
|
||||||
.PARAMETER Program
|
|
||||||
A string containing the name of the Chocolatey package to be installed.
|
|
||||||
|
|
||||||
.PARAMETER currentIndex
|
|
||||||
The current index of the program in the list of programs to be managed.
|
|
||||||
|
|
||||||
.PARAMETER totalPrograms
|
|
||||||
The total number of programs to be installed.
|
|
||||||
|
|
||||||
.DESCRIPTION
|
|
||||||
This function installs a Chocolatey package by running the `choco install` command. If the installation output indicates that an upgrade might be needed, the function will attempt to upgrade the package. The taskbar progress is updated after each package is processed.
|
|
||||||
|
|
||||||
.EXAMPLE
|
|
||||||
Install-ChocoPackage -Program $Program -currentIndex 0 -totalPrograms 5
|
|
||||||
#>
|
|
||||||
|
|
||||||
param (
|
|
||||||
[string]$Program,
|
|
||||||
[int]$currentIndex,
|
|
||||||
[int]$totalPrograms
|
|
||||||
)
|
|
||||||
|
|
||||||
$installOutputFile = "$env:TEMP\Install-WinUtilProgramChoco.install-command.output.txt"
|
|
||||||
Initialize-OutputFile $installOutputFile
|
|
||||||
|
|
||||||
Write-Host "Starting installation of $Program with Chocolatey."
|
|
||||||
|
|
||||||
|
if ($manage -eq "Installing") {
|
||||||
|
write-host "Starting install of $($Program.choco) with Chocolatey."
|
||||||
try {
|
try {
|
||||||
$installStatusCode = Run-ChocoCommand "install $Program -y --log-file $installOutputFile"
|
$tryUpgrade = $false
|
||||||
if ($installStatusCode -eq 0) {
|
$installOutputFilePath = "$env:TEMP\Install-WinUtilProgramChoco.install-command.output.txt"
|
||||||
|
New-Item -ItemType File -Path $installOutputFilePath
|
||||||
if (Check-UpgradeNeeded $installOutputFile) {
|
$chocoInstallStatus = $(Start-Process -FilePath "choco" -ArgumentList "install $($Program.choco) -y --log-file $($installOutputFilePath)" -Wait -PassThru).ExitCode
|
||||||
$upgradeStatusCode = Run-ChocoCommand "upgrade $Program -y"
|
if (($chocoInstallStatus -eq 0) -AND (Test-Path -Path $installOutputFilePath)) {
|
||||||
Write-Host "$Program was" $(if ($upgradeStatusCode -eq 0) { "upgraded successfully." } else { "not upgraded." })
|
$keywordsFound = Get-Content -Path $installOutputFilePath | Where-Object { $_ -match "reinstall" -OR $_ -match "already installed" }
|
||||||
|
if ($keywordsFound) {
|
||||||
|
$tryUpgrade = $true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($tryUpgrade) {
|
||||||
|
$chocoUpdateStatus = $(Start-Process -FilePath "choco" -ArgumentList "upgrade $($Program.choco) -y" -Wait -PassThru).ExitCode
|
||||||
|
if ($chocoUpdateStatus -eq 0) {
|
||||||
|
Write-Host "$($Program.choco) was updated successfully using Chocolatey."
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
Write-Host "$Program installed successfully."
|
Write-Host "Failed upgdate of $($Program.choco) using Chocolatey."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
if (($chocoInstallStatus -eq 0) -AND ($tryUpgrade -eq $false)) {
|
||||||
Write-Host "Failed to install $Program."
|
Write-Host "$($Program.choco) installed successfully using Chocolatey."
|
||||||
|
$X++
|
||||||
|
$sync.form.Dispatcher.Invoke([action] { Set-WinUtilTaskbaritem -state "Normal" -value ($x / $count) })
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
elseif (($chocoInstallStatus -ne 0) -AND ($tryUpgrade -eq $false)) {
|
||||||
|
Write-Host "Failed to install $($Program.choco) using Chocolatey"
|
||||||
|
$X++
|
||||||
|
$sync.form.Dispatcher.Invoke([action] { Set-WinUtilTaskbaritem -state "Error" -value ($x / $count) })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
Write-Host "Failed to install $Program due to an error: $_"
|
Write-Host "Failed to install $($Program.choco) due to an error: $_"
|
||||||
}
|
$X++
|
||||||
finally {
|
$sync.form.Dispatcher.Invoke([action] { Set-WinUtilTaskbaritem -state "Error" -value ($x / $count) })
|
||||||
Update-TaskbarProgress $currentIndex $totalPrograms
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function Uninstall-ChocoPackage {
|
if ($manage -eq "Uninstalling") {
|
||||||
<#
|
Write-Host "Searching for Metapackages of of $($Program.choco) (.install or .portable)"
|
||||||
.SYNOPSIS
|
$chocoPackages = ((choco list | Select-String -Pattern "$($Program.choco)(\.install|\.portable) {0,1}").Matches.Value) -join " "
|
||||||
Uninstalls a Chocolatey package and any related metapackages.
|
Write-Host "Starting uninstall of $chocoPackages with Chocolatey."
|
||||||
|
|
||||||
.PARAMETER Program
|
|
||||||
A string containing the name of the Chocolatey package to be uninstalled.
|
|
||||||
|
|
||||||
.PARAMETER currentIndex
|
|
||||||
The current index of the program in the list of programs to be managed.
|
|
||||||
|
|
||||||
.PARAMETER totalPrograms
|
|
||||||
The total number of programs to be uninstalled.
|
|
||||||
|
|
||||||
.DESCRIPTION
|
|
||||||
This function uninstalls a Chocolatey package and any related metapackages (e.g., .install or .portable variants). It updates the taskbar progress after processing each package.
|
|
||||||
|
|
||||||
.EXAMPLE
|
|
||||||
Uninstall-ChocoPackage -Program $Program -currentIndex 0 -totalPrograms 5
|
|
||||||
#>
|
|
||||||
|
|
||||||
param (
|
|
||||||
[string]$Program,
|
|
||||||
[int]$currentIndex,
|
|
||||||
[int]$totalPrograms
|
|
||||||
)
|
|
||||||
|
|
||||||
$uninstallOutputFile = "$env:TEMP\Install-WinUtilProgramChoco.uninstall-command.output.txt"
|
|
||||||
Initialize-OutputFile $uninstallOutputFile
|
|
||||||
|
|
||||||
Write-Host "Searching for metapackages of $Program (.install or .portable)"
|
|
||||||
$chocoPackages = ((choco list | Select-String -Pattern "$Program(\.install|\.portable)?").Matches.Value) -join " "
|
|
||||||
if ($chocoPackages) {
|
|
||||||
Write-Host "Starting uninstallation of $chocoPackages with Chocolatey."
|
|
||||||
try {
|
try {
|
||||||
$uninstallStatusCode = Run-ChocoCommand "uninstall $chocoPackages -y"
|
$uninstallOutputFilePath = "$env:TEMP\Install-WinUtilProgramChoco.uninstall-command.output.txt"
|
||||||
Write-Host "$Program" $(if ($uninstallStatusCode -eq 0) { "uninstalled successfully." } else { "failed to uninstall." })
|
New-Item -ItemType File -Path $uninstallOutputFilePath
|
||||||
}
|
$chocoUninstallStatus = $(Start-Process -FilePath "choco" -ArgumentList "uninstall $chocoPackages -y" -Wait -PassThru).ExitCode
|
||||||
catch {
|
if ($chocoUninstallStatus -eq 0) {
|
||||||
Write-Host "Failed to uninstall $Program due to an error: $_"
|
Write-Host "$($Program.choco) uninstalled successfully using Chocolatey."
|
||||||
}
|
$x++
|
||||||
finally {
|
$sync.form.Dispatcher.Invoke([action] { Set-WinUtilTaskbaritem -state "Normal" -value ($x / $count) })
|
||||||
Update-TaskbarProgress $currentIndex $totalPrograms
|
continue
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Write-Host "$Program is not installed."
|
Write-Host "Failed to uninstall $($Program.choco) using Chocolatey, Chocolatey output:`n`n$(Get-Content -Path $uninstallOutputFilePath)."
|
||||||
|
$x++
|
||||||
|
$sync.form.Dispatcher.Invoke([action] { Set-WinUtilTaskbaritem -state "Error" -value ($x / $count) })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
Write-Host "Failed to uninstall $($Program.choco) due to an error: $_"
|
||||||
|
$x++
|
||||||
|
$sync.form.Dispatcher.Invoke([action] { Set-WinUtilTaskbaritem -state "Error" -value ($x / $count) })
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$totalPrograms = $Programs.Count
|
# Cleanup leftovers files
|
||||||
if ($totalPrograms -le 0) {
|
if (Test-Path -Path $installOutputFilePath) { Remove-Item -Path $installOutputFilePath }
|
||||||
throw "Parameter 'Programs' must have at least one item."
|
if (Test-Path -Path $uninstallOutputFilePath) { Remove-Item -Path $uninstallOutputFilePath }
|
||||||
}
|
|
||||||
|
|
||||||
Write-Host "==========================================="
|
return;
|
||||||
Write-Host "-- Configuring Chocolatey packages ---"
|
|
||||||
Write-Host "==========================================="
|
|
||||||
|
|
||||||
for ($currentIndex = 0; $currentIndex -lt $totalPrograms; $currentIndex++) {
|
|
||||||
$Program = $Programs[$currentIndex]
|
|
||||||
Set-WinUtilProgressBar -label "$Action $($Program)" -percent ($currentIndex / $totalPrograms * 100)
|
|
||||||
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -value ($currentIndex / $totalPrograms)})
|
|
||||||
|
|
||||||
switch ($Action) {
|
|
||||||
"Install" {
|
|
||||||
Install-ChocoPackage -Program $Program -currentIndex $currentIndex -totalPrograms $totalPrograms
|
|
||||||
}
|
}
|
||||||
"Uninstall" {
|
|
||||||
Uninstall-ChocoPackage -Program $Program -currentIndex $currentIndex -totalPrograms $totalPrograms
|
|
||||||
}
|
|
||||||
default {
|
|
||||||
throw "Invalid action parameter value: '$Action'."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Set-WinUtilProgressBar -label "$($Action)ation done" -percent 100
|
|
||||||
# Cleanup Output Files
|
|
||||||
$outputFiles = @("$env:TEMP\Install-WinUtilProgramChoco.install-command.output.txt", "$env:TEMP\Install-WinUtilProgramChoco.uninstall-command.output.txt")
|
|
||||||
foreach ($filePath in $outputFiles) {
|
|
||||||
Remove-Item -Path $filePath -Force -ErrorAction SilentlyContinue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
Function Install-WinUtilProgramWinget {
|
Function Invoke-WinUtilWingetProgram {
|
||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Runs the designated action on the provided programs using Winget
|
Runs the designated action on the provided programs using Winget
|
@ -29,21 +29,23 @@ function Invoke-WPFInstall {
|
|||||||
}
|
}
|
||||||
$packagesWinget, $packagesChoco = {
|
$packagesWinget, $packagesChoco = {
|
||||||
$packagesWinget = [System.Collections.ArrayList]::new()
|
$packagesWinget = [System.Collections.ArrayList]::new()
|
||||||
$packagesChoco = [System.Collections.ArrayList]::new()
|
$packagesChoco = [System.Collections.Generic.List`1[System.Object]]::new()
|
||||||
|
|
||||||
foreach ($package in $PackagesToInstall) {
|
foreach ($package in $PackagesToInstall) {
|
||||||
if ($ChocoPreference) {
|
if ($ChocoPreference) {
|
||||||
|
Write-Host "Prefer Choco"
|
||||||
if ($package.choco -eq "na") {
|
if ($package.choco -eq "na") {
|
||||||
$packagesWinget.add($package.winget)
|
$packagesWinget.add($package.winget)
|
||||||
Write-Host "Queueing $($package.winget) for Winget install"
|
Write-Host "Queueing $($package.winget) for Winget install"
|
||||||
} else {
|
} else {
|
||||||
$null = $packagesChoco.add($package.choco)
|
$null = $packagesChoco.add($package)
|
||||||
Write-Host "Queueing $($package.choco) for Chocolatey install"
|
Write-Host "Queueing $($package) for Chocolatey install"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
Write-Host "Prefer Winget"
|
||||||
if ($package.winget -eq "na") {
|
if ($package.winget -eq "na") {
|
||||||
$packagesChoco.add($package.choco)
|
$packagesChoco.add($package)
|
||||||
Write-Host "Queueing $($package.choco) for Chocolatey install"
|
Write-Host "Queueing $($package.choco) for Chocolatey install"
|
||||||
} else {
|
} else {
|
||||||
$null = $packagesWinget.add($($package.winget))
|
$null = $packagesWinget.add($($package.winget))
|
||||||
@ -51,6 +53,7 @@ function Invoke-WPFInstall {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $packagesWinget, $packagesChoco
|
return $packagesWinget, $packagesChoco
|
||||||
}.Invoke($PackagesToInstall)
|
}.Invoke($PackagesToInstall)
|
||||||
|
|
||||||
@ -59,12 +62,12 @@ function Invoke-WPFInstall {
|
|||||||
$errorPackages = @()
|
$errorPackages = @()
|
||||||
if($packagesWinget.Count -gt 0) {
|
if($packagesWinget.Count -gt 0) {
|
||||||
Install-WinUtilWinget
|
Install-WinUtilWinget
|
||||||
Install-WinUtilProgramWinget -Action Install -Programs $packagesWinget
|
$errorPackages += Invoke-WinUtilWingetProgram -Action Install -Programs $packagesWinget
|
||||||
|
$errorPackages| ForEach-Object {if($_.choco -ne "na") {$packagesChoco += $_}}
|
||||||
}
|
}
|
||||||
if($packagesChoco.Count -gt 0) {
|
if($packagesChoco.Count -gt 0) {
|
||||||
Install-WinUtilChoco
|
Install-WinUtilChoco
|
||||||
Install-WinUtilProgramChoco -Action Install -Programs $packagesChoco
|
Install-WinUtilProgramChoco -ProgramsToInstall $packagesChoco
|
||||||
}
|
}
|
||||||
Write-Host "==========================================="
|
Write-Host "==========================================="
|
||||||
Write-Host "-- Installs have finished ---"
|
Write-Host "-- Installs have finished ---"
|
||||||
|
@ -263,8 +263,11 @@ public class PowerManagement {
|
|||||||
# reg delete "HKLM\zSOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Orchestrator\UScheduler\$_" /f | Out-Null
|
# reg delete "HKLM\zSOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Orchestrator\UScheduler\$_" /f | Out-Null
|
||||||
|
|
||||||
# When in Offline Image
|
# When in Offline Image
|
||||||
|
if (Test-Path "HKLM:\zSOFTWARE\Microsoft\WindowsUpdate\Orchestrator\UScheduler_Oobe\$_")
|
||||||
|
{
|
||||||
reg delete "HKLM\zSOFTWARE\Microsoft\WindowsUpdate\Orchestrator\UScheduler_Oobe\$_" /f | Out-Null
|
reg delete "HKLM\zSOFTWARE\Microsoft\WindowsUpdate\Orchestrator\UScheduler_Oobe\$_" /f | Out-Null
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
reg add "HKLM\zSOFTWARE\Microsoft\Windows\CurrentVersion\Search" /v "SearchboxTaskbarMode" /t REG_DWORD /d 0 /f
|
reg add "HKLM\zSOFTWARE\Microsoft\Windows\CurrentVersion\Search" /v "SearchboxTaskbarMode" /t REG_DWORD /d 0 /f
|
||||||
Write-Host "Setting all services to start manually"
|
Write-Host "Setting all services to start manually"
|
||||||
|
@ -17,7 +17,7 @@ function Invoke-WPFTweakPS7{
|
|||||||
Write-Host "Powershell 7 is already installed."
|
Write-Host "Powershell 7 is already installed."
|
||||||
} else {
|
} else {
|
||||||
Write-Host "Installing Powershell 7..."
|
Write-Host "Installing Powershell 7..."
|
||||||
Install-WinUtilProgramWinget -Action Install -Programs @("Microsoft.PowerShell")
|
Invoke-WinUtilWingetProgram -Action Install -Programs @("Microsoft.PowerShell")
|
||||||
}
|
}
|
||||||
$targetTerminalName = "PowerShell"
|
$targetTerminalName = "PowerShell"
|
||||||
}
|
}
|
||||||
|
@ -38,41 +38,40 @@ function Invoke-WPFUnInstall {
|
|||||||
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "Normal" -value 0.01 -overlay "logo" })
|
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "Normal" -value 0.01 -overlay "logo" })
|
||||||
}
|
}
|
||||||
$packagesWinget, $packagesChoco = {
|
$packagesWinget, $packagesChoco = {
|
||||||
$packagesWinget = [System.Collections.ArrayList]::new()
|
$packagesWinget = [System.Collections.Generic.List`1[System.Object]]::new()
|
||||||
$packagesChoco = [System.Collections.ArrayList]::new()
|
$packagesChoco = [System.Collections.Generic.List`1[System.Object]]::new()
|
||||||
|
|
||||||
foreach ($package in $PackagesToInstall) {
|
foreach ($package in $PackagesToInstall) {
|
||||||
if ($ChocoPreference) {
|
if ($ChocoPreference) {
|
||||||
if ($package.choco -eq "na") {
|
if ($packagesChoco.choco -eq "na") {
|
||||||
$packagesWinget.add($package.winget)
|
$null = $packagesWinget.add($package.winget)
|
||||||
Write-Host "Queueing $($package.winget) for Winget uninstall"
|
Write-Host "Queueing $($package.winget) for Winget Uninstall"
|
||||||
} else {
|
}
|
||||||
$null = $packagesChoco.add($package.choco)
|
else {
|
||||||
Write-Host "Queueing $($package.choco) for Chocolatey uninstall"
|
$packagesChoco.add($package)
|
||||||
|
Write-Host "Queueing $($package.choco) for Chocolatey Uninstall"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if ($package.winget -eq "na") {
|
if ($package.winget -eq "na") {
|
||||||
$packagesChoco.add($package.choco)
|
$packagesChoco.add($package)
|
||||||
Write-Host "Queueing $($package.choco) for Chocolatey uninstall"
|
Write-Host "Queueing $($package.choco) for Chocolatey Uninstall"
|
||||||
} else {
|
} else {
|
||||||
$null = $packagesWinget.add($($package.winget))
|
$null = $packagesWinget.add($($package.winget))
|
||||||
Write-Host "Queueing $($package.winget) for Winget uninstall"
|
Write-Host "Queueing $($package.winget) for Winget Uninstall"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $packagesWinget, $packagesChoco
|
return $packagesWinget, $packagesChoco
|
||||||
}.Invoke($PackagesToInstall)
|
}.Invoke($PackagesToInstall)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$sync.ProcessRunning = $true
|
$sync.ProcessRunning = $true
|
||||||
|
|
||||||
# Install all selected programs in new window
|
# Install all selected programs in new window
|
||||||
if($packagesWinget.Count -gt 0) {
|
if($packagesWinget.Count -gt 0) {
|
||||||
Install-WinUtilProgramWinget -Action Uninstall -Programs $packagesWinget
|
Invoke-WinUtilWingetProgram -Action Uninstall -Programs $packagesWinget
|
||||||
}
|
}
|
||||||
if($packagesChoco.Count -gt 0) {
|
if($packagesChoco.Count -gt 0) {
|
||||||
Install-WinUtilProgramChoco -Action Uninstall -Programs $packagesChoco
|
Install-WinUtilProgramChoco -ProgramsToInstall $packagesChoco -Manage "Uninstalling"
|
||||||
}
|
}
|
||||||
|
|
||||||
Write-Host "==========================================="
|
Write-Host "==========================================="
|
||||||
|
Loading…
Reference in New Issue
Block a user