Compile Winutil

This commit is contained in:
ChrisTitusTech 2024-07-31 02:13:58 +00:00 committed by github-actions[bot]
parent e7328c2739
commit 128593a950

View File

@ -997,122 +997,6 @@ function Install-WinUtilProgramChoco {
return;
}
Function Install-WinUtilProgramWinget {
<#
.SYNOPSIS
Manages the provided programs using Winget
.PARAMETER ProgramsToInstall
A list of programs to manage
.PARAMETER manage
The action to perform on the programs, can be either 'Installing' or 'Uninstalling'
.NOTES
The triple quotes are required any time you need a " in a normal script block.
The winget Return codes are documented here: https://github.com/microsoft/winget-cli/blob/master/doc/windows/package-manager/winget/returnCodes.md
#>
param(
[Parameter(Mandatory, Position=0)]
[PsCustomObject]$ProgramsToInstall,
[Parameter(Position=1)]
[String]$manage = "Installing"
)
$count = $ProgramsToInstall.Count
Write-Progress -Activity "$manage Applications" -Status "Starting" -PercentComplete 0
Write-Host "==========================================="
Write-Host "-- Configuring winget packages ---"
Write-Host "==========================================="
for ($i = 0; $i -lt $count; $i++) {
$Program = $ProgramsToInstall[$i]
$failedPackages = @()
Write-Progress -Activity "$manage Applications" -Status "$manage $($Program.winget) $($i + 1) of $count" -PercentComplete $((($i + 1)/$count) * 100)
if($manage -eq "Installing") {
# Install package via ID, if it fails try again with different scope and then with an unelevated prompt.
# Since Install-WinGetPackage might not be directly available, we use winget install command as a workaround.
# Winget, not all installers honor any of the following: System-wide, User Installs, or Unelevated Prompt OR Silent Install Mode.
# This is up to the individual package maintainers to enable these options. Aka. not as clean as Linux Package Managers.
Write-Host "Starting install of $($Program.winget) with winget."
try {
$status = $(Start-Process -FilePath "winget" -ArgumentList "install --id $($Program.winget) --silent --accept-source-agreements --accept-package-agreements" -Wait -PassThru -NoNewWindow).ExitCode
if($status -eq 0) {
Write-Host "$($Program.winget) installed successfully."
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -value ($x/$count) })
continue
}
if ($status -eq -1978335189) {
Write-Host "$($Program.winget) No applicable update found"
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -value ($x/$count) })
continue
}
Write-Host "Attempt with User scope"
$status = $(Start-Process -FilePath "winget" -ArgumentList "install --id $($Program.winget) --scope user --silent --accept-source-agreements --accept-package-agreements" -Wait -PassThru -NoNewWindow).ExitCode
if($status -eq 0) {
Write-Host "$($Program.winget) installed successfully with User scope."
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -value ($x/$count) })
continue
}
if ($status -eq -1978335189) {
Write-Host "$($Program.winget) No applicable update found"
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -value ($x/$count) })
continue
}
Write-Host "Attempt with User prompt"
$userChoice = [System.Windows.MessageBox]::Show("Do you want to attempt $($Program.winget) installation with specific user credentials? Select 'Yes' to proceed or 'No' to skip.", "User Credential Prompt", [System.Windows.MessageBoxButton]::YesNo)
if ($userChoice -eq 'Yes') {
$getcreds = Get-Credential
$process = Start-Process -FilePath "winget" -ArgumentList "install --id $($Program.winget) --silent --accept-source-agreements --accept-package-agreements" -Credential $getcreds -PassThru -NoNewWindow
Wait-Process -Id $process.Id
$status = $process.ExitCode
} else {
Write-Host "Skipping installation with specific user credentials."
}
if($status -eq 0) {
Write-Host "$($Program.winget) installed successfully with User prompt."
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -value ($x/$count) })
continue
}
if ($status -eq -1978335189) {
Write-Host "$($Program.winget) No applicable update found"
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -value ($x/$count) })
continue
}
} catch {
Write-Host "Failed to install $($Program.winget). With winget"
$failedPackages += $Program
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "Error" -value ($x/$count) })
}
}
elseif($manage -eq "Uninstalling") {
# Uninstall package via ID using winget directly.
try {
$status = $(Start-Process -FilePath "winget" -ArgumentList "uninstall --id $($Program.winget) --silent" -Wait -PassThru -NoNewWindow).ExitCode
if($status -ne 0) {
Write-Host "Failed to uninstall $($Program.winget)."
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "Error" })
} else {
Write-Host "$($Program.winget) uninstalled successfully."
$failedPackages += $Program
}
} catch {
Write-Host "Failed to uninstall $($Program.winget) due to an error: $_"
$failedPackages += $Program
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "Error" })
}
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -value ($x/$count) })
}
else {
throw "[Install-WinUtilProgramWinget] Invalid Value for Parameter 'manage', Provided Value is: $manage"
}
}
Write-Progress -Activity "$manage Applications" -Status "Finished" -Completed
return $failedPackages;
}
function Install-WinUtilWinget {
<#
@ -2765,6 +2649,177 @@ function Invoke-WinUtilVerboseLogon {
Write-Warning $psitem.Exception.StackTrace
}
}
Function Invoke-WinUtilWingetProgram {
<#
.SYNOPSIS
Runs the designated action on the provided programs using Winget
.PARAMETER Programs
A list of programs to process
.PARAMETER action
The action to perform on the programs, can be either 'Install' or 'Uninstall'
.NOTES
The triple quotes are required any time you need a " in a normal script block.
The winget Return codes are documented here: https://github.com/microsoft/winget-cli/blob/master/doc/windows/package-actionr/winget/returnCodes.md
#>
param(
[Parameter(Mandatory, Position=0)]
$Programs,
[Parameter(Mandatory, Position=1)]
[ValidateSet("Install", "Uninstall")]
[String]$Action
)
Function Invoke-Winget {
<#
.SYNOPSIS
Invokes the winget.exe with the provided arguments and return the exit code
.PARAMETER wingetId
The Id of the Program that Winget should Install/Uninstall
.PARAMETER scope
Determines the installation mode. Can be "user" or "machine" (For more info look at the winget documentation)
.PARAMETER credential
The PSCredential Object of the user that should be used to run winget
.NOTES
Invoke Winget uses the public variable $Action defined outside the function to determine if a Program should be installed or removed
#>
param (
[string]$wingetId,
[string]$scope = "",
[PScredential]$credential = $null
)
$commonArguments = "--id $wingetId --silent"
$arguments = if ($Action -eq "Install"){
"install $commonArguments --accept-source-agreements --accept-package-agreements $(if ($scope) {" --scope $scope"})"
}
else {
"uninstall $commonArguments"
}
$processParams = @{
FilePath = "winget"
ArgumentList = $arguments
Wait = $true
PassThru = $true
NoNewWindow = $true
}
if ($credential) {
$processParams.credential = $credential
}
return (Start-Process @processParams).ExitCode
}
Function Invoke-Install {
<#
.SYNOPSIS
Contains the Install Logic and return code handling from winget
.PARAMETER Program
The Winget ID of the Program that should be installed
#>
param (
[string]$Program
)
$status = Invoke-Winget -wingetId $Program
if ($status -eq 0) {
Write-Host "$($Program) installed successfully."
return $true
} elseif ($status -eq -1978335189) {
Write-Host "$($Program) No applicable update found"
return $true
}
Write-Host "Attempt installation of $($Program) with User scope"
$status = Invoke-Winget -wingetId $Program -scope "user"
if ($status -eq 0) {
Write-Host "$($Program) installed successfully with User scope."
return $true
} elseif ($status -eq -1978335189) {
Write-Host "$($Program) No applicable update found"
return $true
}
$userChoice = [System.Windows.MessageBox]::Show("Do you want to attempt $($Program) installation with specific user credentials? Select 'Yes' to proceed or 'No' to skip.", "User credential Prompt", [System.Windows.MessageBoxButton]::YesNo)
if ($userChoice -eq 'Yes') {
$getcreds = Get-Credential
$status = Invoke-Winget -wingetId $Program -credential $getcreds
if ($status -eq 0) {
Write-Host "$($Program) installed successfully with User prompt."
return $true
}
} else {
Write-Host "Skipping installation with specific user credentials."
}
Write-Host "Failed to install $($Program)."
return $false
}
Function Invoke-Uninstall {
<#
.SYNOPSIS
Contains the Uninstall Logic and return code handling from winget
.PARAMETER Program
The Winget ID of the Program that should be uninstalled
#>
param (
[psobject]$Program
)
try {
$status = Invoke-Winget -wingetId $Program
if ($status -eq 0) {
Write-Host "$($Program) uninstalled successfully."
return $true
} else {
Write-Host "Failed to uninstall $($Program)."
return $false
}
} catch {
Write-Host "Failed to uninstall $($Program) due to an error: $_"
return $false
}
}
$count = $Programs.Count
$failedPackages = @()
Write-Host "==========================================="
Write-Host "-- Configuring winget packages ---"
Write-Host "==========================================="
for ($i = 0; $i -lt $count; $i++) {
$Program = $Programs[$i]
$result = $false
Set-WinUtilProgressBar -label "$Action $($Program)" -percent ($i / $count * 100)
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -value ($i / $count)})
$result = switch ($Action) {
"Install" {Invoke-Install -Program $Program}
"Uninstall" {Invoke-Uninstall -Program $Program}
default {throw "[Install-WinUtilProgramWinget] Invalid action: $Action"}
}
if (-not $result) {
$failedPackages += $Program
}
}
Set-WinUtilProgressBar -label "$($Action)ation done" -percent 100
return $failedPackages
}
function Remove-WinUtilAPPX {
<#
@ -2836,6 +2891,37 @@ function Set-WinUtilDNS {
Write-Warning $psitem.Exception.StackTrace
}
}
function Set-WinUtilProgressbar{
<#
.SYNOPSIS
This function is used to Update the Progress Bar displayed in the winutil GUI.
It will be automatically hidden if the user clicks something and no process is running
.PARAMETER Label
The Text to be overlayed onto the Progress Bar
.PARAMETER PERCENT
The percentage of the Progress Bar that should be filled (0-100)
.PARAMETER Hide
If provided, the Progress Bar and the label will be hidden
#>
param(
[string]$Label,
[ValidateRange(0,100)]
[int]$Percent,
$Hide
)
if ($hide){
$sync.form.Dispatcher.Invoke([action]{$sync.ProgressBarLabel.Visibility = "Collapsed"})
$sync.form.Dispatcher.Invoke([action]{$sync.ProgressBar.Visibility = "Collapsed"})
}
else{
$sync.form.Dispatcher.Invoke([action]{$sync.ProgressBarLabel.Visibility = "Visible"})
$sync.form.Dispatcher.Invoke([action]{$sync.ProgressBar.Visibility = "Visible"})
}
$sync.form.Dispatcher.Invoke([action]{$sync.ProgressBarLabel.Content.Text = $label})
$sync.form.Dispatcher.Invoke([action]{$sync.ProgressBarLabel.Content.ToolTip = $label})
$sync.form.Dispatcher.Invoke([action]{ $sync.ProgressBar.Value = $percent})
}
function Set-WinUtilRegistry {
<#
@ -3568,6 +3654,9 @@ function Invoke-WPFButton {
# Use this to get the name of the button
#[System.Windows.MessageBox]::Show("$Button","Chris Titus Tech's Windows Utility","OK","Info")
if (-not $sync.ProcessRunning){
Set-WinUtilProgressBar -label "" -percent 0 -hide $true
}
Switch -Wildcard ($Button){
@ -4442,14 +4531,14 @@ function Invoke-WPFInstall {
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "Normal" -value 0.01 -overlay "logo" })
}
$packagesWinget, $packagesChoco = {
$packagesWinget = [System.Collections.Generic.List`1[System.Object]]::new()
$packagesWinget = [System.Collections.ArrayList]::new()
$packagesChoco = [System.Collections.Generic.List`1[System.Object]]::new()
foreach ($package in $PackagesToInstall) {
if ($package.winget -eq "na") {
$packagesChoco.add($package)
Write-Host "Queueing $($package.choco) for Chocolatey install"
} else {
$packagesWinget.add($package)
$null = $packagesWinget.add($($package.winget))
Write-Host "Queueing $($package.winget) for Winget install"
}
}
@ -4461,7 +4550,7 @@ function Invoke-WPFInstall {
$errorPackages = @()
if($packagesWinget.Count -gt 0){
Install-WinUtilWinget
$errorPackages += Install-WinUtilProgramWinget -ProgramsToInstall $packagesWinget
$errorPackages += Invoke-WinUtilWingetProgram -Action Install -Programs $packagesWinget
$errorPackages| ForEach-Object {if($_.choco -ne "na") {$packagesChoco += $_}}
}
if($packagesChoco.Count -gt 0){
@ -5378,7 +5467,7 @@ function Invoke-WPFTweakPS7{
Write-Host "Powershell 7 is already installed."
} else {
Write-Host "Installing Powershell 7..."
Install-WinUtilProgramWinget -ProgramsToInstall @(@{"winget"="Microsoft.PowerShell"})
Invoke-WinUtilWingetProgram -Action Install -Programs @("Microsoft.PowerShell")
}
$targetTerminalName = "PowerShell"
}
@ -5449,15 +5538,14 @@ function Invoke-WPFtweaksbutton {
} else {
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "Normal" -value 0.01 -overlay "logo" })
}
$cnt = 0
# Execute other selected tweaks
foreach ($tweak in $Tweaks) {
Write-Debug "This is a tweak to run $tweak count: $cnt"
Invoke-WinUtilTweaks $tweak
$cnt += 1
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -value ($cnt/$Tweaks.Count) })
}
for ($i = 0; $i -lt $Tweaks.Count; $i++){
Set-WinUtilProgressBar -Label "Applying $($tweaks[$i])" -Percent ($i / $Tweaks.Count * 100)
Invoke-WinUtilTweaks $tweaks[$i]
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -value ($i/$Tweaks.Count) })
}
Set-WinUtilProgressBar -Label "Tweaks finished" -Percent 100
$sync.ProcessRunning = $false
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "None" -overlay "checkmark" })
Write-Host "================================="
@ -5538,7 +5626,7 @@ function Invoke-WPFundoall {
return
}
$Tweaks = (Get-WinUtilCheckBoxes)["WPFTweaks"]
$tweaks = (Get-WinUtilCheckBoxes)["WPFtweaks"]
if ($tweaks.count -eq 0){
$msg = "Please check the tweaks you wish to undo."
@ -5546,188 +5634,31 @@ function Invoke-WPFundoall {
return
}
Invoke-WPFRunspace -ArgumentList $Tweaks -DebugPreference $DebugPreference -ScriptBlock {
param($Tweaks, $DebugPreference)
Invoke-WPFRunspace -ArgumentList $tweaks -DebugPreference $DebugPreference -ScriptBlock {
param($tweaks, $DebugPreference)
$sync.ProcessRunning = $true
if ($Tweaks.count -eq 1){
if ($tweaks.count -eq 1){
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "Indeterminate" -value 0.01 -overlay "logo" })
} else {
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "Normal" -value 0.01 -overlay "logo" })
}
$cnt = 0
Foreach ($tweak in $tweaks){
Invoke-WinUtilTweaks $tweak -undo $true
$cnt += 1
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -value ($cnt/$Tweaks.Count) })
for ($i = 0; $i -lt $tweaks.Count; $i++){
Set-WinUtilProgressBar -Label "Undoing $($tweaks[$i])" -Percent ($i / $tweaks.Count * 100)
Invoke-WinUtiltweaks $tweaks[$i] -undo $true
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -value ($i/$tweaks.Count) })
}
Set-WinUtilProgressBar -Label "Undo Tweaks Finished" -Percent 100
$sync.ProcessRunning = $false
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "None" -overlay "checkmark" })
Write-Host "=================================="
Write-Host "--- Undo Tweaks are Finished ---"
Write-Host "=================================="
$ButtonType = [System.Windows.MessageBoxButton]::OK
$MessageboxTitle = "Tweaks are Finished "
$Messageboxbody = ("Done")
$MessageIcon = [System.Windows.MessageBoxImage]::Information
[System.Windows.MessageBox]::Show($Messageboxbody, $MessageboxTitle, $ButtonType, $MessageIcon)
}
<#
Write-Host "Creating Restore Point in case something bad happens"
Enable-ComputerRestore -Drive "$env:SystemDrive"
Checkpoint-Computer -Description "RestorePoint1" -RestorePointType "MODIFY_SETTINGS"
Write-Host "Enabling Telemetry..."
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection" -Name "AllowTelemetry" -Type DWord -Value 1
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DataCollection" -Name "AllowTelemetry" -Type DWord -Value 1
Write-Host "Enabling Wi-Fi Sense"
Set-ItemProperty -Path "HKLM:\Software\Microsoft\PolicyManager\default\WiFi\AllowWiFiHotSpotReporting" -Name "Value" -Type DWord -Value 1
Set-ItemProperty -Path "HKLM:\Software\Microsoft\PolicyManager\default\WiFi\AllowAutoConnectToWiFiSenseHotspots" -Name "Value" -Type DWord -Value 1
Write-Host "Enabling Application suggestions..."
Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -Name "ContentDeliveryAllowed" -Type DWord -Value 1
Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -Name "OemPreInstalledAppsEnabled" -Type DWord -Value 1
Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -Name "PreInstalledAppsEnabled" -Type DWord -Value 1
Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -Name "PreInstalledAppsEverEnabled" -Type DWord -Value 1
Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -Name "SilentInstalledAppsEnabled" -Type DWord -Value 1
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -Name "SubscribedContent-338387Enabled" -Type DWord -Value 1
Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -Name "SubscribedContent-338388Enabled" -Type DWord -Value 1
Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -Name "SubscribedContent-338389Enabled" -Type DWord -Value 1
Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -Name "SubscribedContent-353698Enabled" -Type DWord -Value 1
Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -Name "SystemPaneSuggestionsEnabled" -Type DWord -Value 1
If (Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CloudContent") {
Remove-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CloudContent" -Recurse -ErrorAction SilentlyContinue
}
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CloudContent" -Name "DisableWindowsConsumerFeatures" -Type DWord -Value 0
Write-Host "Enabling Activity History..."
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\System" -Name "EnableActivityFeed" -Type DWord -Value 1
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\System" -Name "PublishUserActivities" -Type DWord -Value 1
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\System" -Name "UploadUserActivities" -Type DWord -Value 1
Write-Host "Enable Location Tracking..."
If (Test-Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\location") {
Remove-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\location" -Recurse -ErrorAction SilentlyContinue
}
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\location" -Name "Value" -Type String -Value "Allow"
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Sensor\Overrides\{BFA794E4-F964-4FDB-90F6-51056BFE4B44}" -Name "SensorPermissionState" -Type DWord -Value 1
Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\lfsvc\Service\Configuration" -Name "Status" -Type DWord -Value 1
Write-Host "Enabling automatic Maps updates..."
Set-ItemProperty -Path "HKLM:\SYSTEM\Maps" -Name "AutoUpdateEnabled" -Type DWord -Value 1
Write-Host "Enabling Feedback..."
If (Test-Path "HKCU:\SOFTWARE\Microsoft\Siuf\Rules") {
Remove-Item -Path "HKCU:\SOFTWARE\Microsoft\Siuf\Rules" -Recurse -ErrorAction SilentlyContinue
}
Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Siuf\Rules" -Name "NumberOfSIUFInPeriod" -Type DWord -Value 0
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DataCollection" -Name "DoNotShowFeedbackNotifications" -Type DWord -Value 0
Write-Host "Enabling Tailored Experiences..."
If (Test-Path "HKCU:\SOFTWARE\Policies\Microsoft\Windows\CloudContent") {
Remove-Item -Path "HKCU:\SOFTWARE\Policies\Microsoft\Windows\CloudContent" -Recurse -ErrorAction SilentlyContinue
}
Set-ItemProperty -Path "HKCU:\SOFTWARE\Policies\Microsoft\Windows\CloudContent" -Name "DisableTailoredExperiencesWithDiagnosticData" -Type DWord -Value 0
Write-Host "Disabling Advertising ID..."
If (Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\AdvertisingInfo") {
Remove-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\AdvertisingInfo" -Recurse -ErrorAction SilentlyContinue
}
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\AdvertisingInfo" -Name "DisabledByGroupPolicy" -Type DWord -Value 0
Write-Host "Allow Error reporting..."
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting" -Name "Disabled" -Type DWord -Value 0
Write-Host "Allowing Diagnostics Tracking Service..."
Stop-Service "DiagTrack" -WarningAction SilentlyContinue
Set-Service "DiagTrack" -StartupType Manual
Write-Host "Allowing WAP Push Service..."
Stop-Service "dmwappushservice" -WarningAction SilentlyContinue
Set-Service "dmwappushservice" -StartupType Manual
Write-Host "Allowing Home Groups services..."
Stop-Service "HomeGroupListener" -WarningAction SilentlyContinue
Set-Service "HomeGroupListener" -StartupType Manual
Stop-Service "HomeGroupProvider" -WarningAction SilentlyContinue
Set-Service "HomeGroupProvider" -StartupType Manual
Write-Host "Enabling Storage Sense..."
New-Item -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy" | Out-Null
Write-Host "Allowing Superfetch service..."
Stop-Service "SysMain" -WarningAction SilentlyContinue
Set-Service "SysMain" -StartupType Manual
Write-Host "Setting BIOS time to Local Time instead of UTC..."
Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\TimeZoneInformation" -Name "RealTimeIsUniversal" -Type DWord -Value 0
Write-Host "Enabling Hibernation..."
Set-ItemProperty -Path "HKLM:\System\CurrentControlSet\Control\Session Manager\Power" -Name "HibernteEnabled" -Type Dword -Value 1
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FlyoutMenuSettings" -Name "ShowHibernateOption" -Type Dword -Value 1
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Personalization" -Name "NoLockScreen" -ErrorAction SilentlyContinue
Write-Host "Hiding file operations details..."
If (Test-Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\OperationStatusManager") {
Remove-Item -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\OperationStatusManager" -Recurse -ErrorAction SilentlyContinue
}
Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\OperationStatusManager" -Name "EnthusiastMode" -Type DWord -Value 0
Write-Host "Showing Task View button..."
Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "ShowTaskViewButton" -Type DWord -Value 1
Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\People" -Name "PeopleBand" -Type DWord -Value 1
Write-Host "Changing default Explorer view to Quick Access..."
Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "LaunchTo" -Type DWord -Value 0
Write-Host "Unrestricting AutoLogger directory"
$autoLoggerDir = "$env:PROGRAMDATA\Microsoft\Diagnosis\ETLLogs\AutoLogger"
icacls $autoLoggerDir /grant:r SYSTEM:`(OI`)`(CI`)F | Out-Null
Write-Host "Enabling and starting Diagnostics Tracking Service"
Set-Service "DiagTrack" -StartupType Automatic
Start-Service "DiagTrack"
Write-Host "Hiding known file extensions"
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "HideFileExt" -Type DWord -Value 1
Write-Host "Reset Local Group Policies to Stock Defaults"
# cmd /c secedit /configure /cfg %windir%\inf\defltbase.inf /db defltbase.sdb /verbose
cmd /c RD /S /Q "%WinDir%\System32\GroupPolicyUsers"
cmd /c RD /S /Q "%WinDir%\System32\GroupPolicy"
cmd /c gpupdate /force
# Considered using Invoke-GPUpdate but requires module most people won't have installed
Write-Host "Adjusting visual effects for appearance..."
Set-ItemProperty -Path "HKCU:\Control Panel\Desktop" -Name "DragFullWindows" -Type String -Value 1
Set-ItemProperty -Path "HKCU:\Control Panel\Desktop" -Name "MenuShowDelay" -Type String -Value 400
Set-ItemProperty -Path "HKCU:\Control Panel\Desktop" -Name "UserPreferencesMask" -Type Binary -Value ([byte[]](158, 30, 7, 128, 18, 0, 0, 0))
Set-ItemProperty -Path "HKCU:\Control Panel\Desktop\WindowMetrics" -Name "MinAnimate" -Type String -Value 1
Set-ItemProperty -Path "HKCU:\Control Panel\Keyboard" -Name "KeyboardDelay" -Type DWord -Value 1
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "ListviewAlphaSelect" -Type DWord -Value 1
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "ListviewShadow" -Type DWord -Value 1
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "TaskbarAnimations" -Type DWord -Value 1
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects" -Name "VisualFXSetting" -Type DWord -Value 3
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\DWM" -Name "EnableAeroPeek" -Type DWord -Value 1
Remove-ItemProperty -Path "HKCU:\Control Panel\Desktop" -Name "HungAppTimeout" -ErrorAction SilentlyContinue
Write-Host "Restoring Clipboard History..."
Remove-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Clipboard" -Name "EnableClipboardHistory" -ErrorAction SilentlyContinue
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\System" -Name "AllowClipboardHistory" -ErrorAction SilentlyContinue
Write-Host "Enabling Notifications and Action Center"
Remove-Item -Path HKCU:\SOFTWARE\Policies\Microsoft\Windows\Explorer -Force
Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\PushNotifications" -Name "ToastEnabled"
Write-Host "Restoring Default Right Click Menu Layout"
Remove-Item -Path "HKCU:\Software\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}" -Recurse -Confirm:$false -Force
Write-Host "Reset News and Interests"
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Feeds" -Name "EnableFeeds" -Type DWord -Value 1
# Remove "News and Interest" from taskbar
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Feeds" -Name "ShellFeedsTaskbarViewMode" -Type DWord -Value 0
Write-Host "Done - Reverted to Stock Settings"
Write-Host "Essential Undo Completed"
$ButtonType = [System.Windows.MessageBoxButton]::OK
$MessageboxTitle = "Undo All"
$Messageboxbody = ("Done")
$MessageIcon = [System.Windows.MessageBoxImage]::Information
[System.Windows.MessageBox]::Show($Messageboxbody, $MessageboxTitle, $ButtonType, $MessageIcon)
Write-Host "================================="
Write-Host "--- Undo All is Finished ---"
Write-Host "================================="
#>
}
function Invoke-WPFUnInstall {
<#
@ -5776,7 +5707,7 @@ function Invoke-WPFUnInstall {
$packagesChoco.add($package)
Write-Host "Queueing $($package.choco) for Chocolatey Uninstall"
} else {
$packagesWinget.add($package)
$packagesWinget.add($($package.winget))
Write-Host "Queueing $($package.winget) for Winget Uninstall"
}
}
@ -5787,14 +5718,12 @@ function Invoke-WPFUnInstall {
# Install all selected programs in new window
if($packagesWinget.Count -gt 0){
Install-WinUtilProgramWinget -ProgramsToInstall $packagesWinget -Manage "Uninstalling"
Invoke-WinUtilWingetProgram -Action Uninstall -Programs $packagesWinget
}
if($packagesChoco.Count -gt 0){
Install-WinUtilProgramChoco -ProgramsToInstall $packagesChoco -Manage "Uninstalling"
}
[System.Windows.MessageBox]::Show($Messageboxbody, $MessageboxTitle, $ButtonType, $MessageIcon)
Write-Host "==========================================="
Write-Host "-- Uninstalls have finished ---"
Write-Host "==========================================="
@ -9271,6 +9200,9 @@ $sync.configs.themes = '{
"WinUtilIconSize": "Auto",
"SettingsIconFontSize": "18",
"MicroWinLogoSize": "10",
"ProgressBarForegroundColor": "#FFAC1C",
"ProgressBarBackgroundColor": "Transparent",
"ProgressBarTextColor": "#000000",
"ComboBoxBackgroundColor": "#FFFFFF",
"LabelboxForegroundColor": "#000000",
"MainForegroundColor": "#000000",
@ -9332,6 +9264,9 @@ $sync.configs.themes = '{
"WinUtilIconSize": "Auto",
"SettingsIconFontSize": "18",
"MicroWinLogoSize": "10",
"ProgressBarForegroundColor": "#222222",
"ProgressBarBackgroundColor": "Transparent",
"ProgressBarTextColor": "#cccccc",
"ComboBoxBackgroundColor": "#000000",
"LabelboxForegroundColor": "#FFEE58",
"MainForegroundColor": "#9CCC65",
@ -9391,6 +9326,9 @@ $sync.configs.themes = '{
"WinUtilIconSize": "Auto",
"SettingsIconFontSize": "18",
"MicroWinLogoSize": "10",
"ProgressBarForegroundColor": "#222222",
"ProgressBarBackgroundColor": "Transparent",
"ProgressBarTextColor": "#FFFFFF",
"ComboBoxBackgroundColor": "#000000",
"LabelboxForegroundColor": "#FFEE58",
"MainForegroundColor": "#9CCC65",
@ -13295,6 +13233,7 @@ $inputXML = '<Window x:Class="WinUtility.MainWindow"
</ToggleButton>
<Grid Background="{MainBackgroundColor}" ShowGridLines="False" Width="Auto" Height="Auto" HorizontalAlignment="Stretch">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="50px"/>
<ColumnDefinition Width="50px"/>
@ -13315,7 +13254,7 @@ $inputXML = '<Window x:Class="WinUtility.MainWindow"
Height="{SearchBarHeight}"
FontSize="{SearchBarTextBoxFontSize}"
VerticalAlignment="Center" HorizontalAlignment="Left"
Margin="10,0,0,0" BorderThickness="1" Padding="22,2,2,2"
BorderThickness="1"
Name="SearchBar"
Foreground="{MainForegroundColor}" Background="{MainBackgroundColor}"
ToolTip="Press Ctrl-F and type app name to filter application list below. Press Esc to reset the filter">
@ -13339,9 +13278,38 @@ $inputXML = '<Window x:Class="WinUtility.MainWindow"
Style="{StaticResource SearchBarClearButtonStyle}"
Margin="193,0,0,0" Visibility="Collapsed"/>
<ProgressBar
Grid.Column="1"
Minimum="0"
Maximum="100"
Width="250"
Height="{SearchBarHeight}"
Foreground="{ProgressBarForegroundColor}" Background="{ProgressBarBackgroundColor}" BorderBrush="{ProgressBarForegroundColor}"
Visibility="Collapsed"
VerticalAlignment="Center" HorizontalAlignment="Left"
Margin="2,0,0,0" BorderThickness="1" Padding="6,2,2,2"
Name="ProgressBar">
</ProgressBar>
<Label
Grid.Column="1"
Width="250"
Height="{SearchBarHeight}"
VerticalAlignment="Center" HorizontalAlignment="Left"
FontSize="{SearchBarTextBoxFontSize}"
Background="Transparent"
Visibility="Collapsed"
Margin="2,0,0,0" BorderThickness="0" Padding="6,2,2,2"
Name="ProgressBarLabel">
<TextBlock
TextTrimming="CharacterEllipsis"
Background="Transparent"
Foreground="{ProgressBarTextColor}">
</TextBlock>
</Label>
<Button Name="SettingsButton"
Style="{StaticResource HoverButtonStyle}"
Grid.Column="1" BorderBrush="Transparent"
Grid.Column="2" BorderBrush="Transparent"
Background="{MainBackgroundColor}"
Foreground="{MainForegroundColor}"
FontSize="{SettingsIconFontSize}"
@ -13350,7 +13318,7 @@ $inputXML = '<Window x:Class="WinUtility.MainWindow"
Margin="0,5,5,0"
FontFamily="Segoe MDL2 Assets"
Content="&#xE713;"/>
<Popup Grid.Column="1" Name="SettingsPopup"
<Popup Grid.Column="2" Name="SettingsPopup"
IsOpen="False"
PlacementTarget="{Binding ElementName=SettingsButton}" Placement="Bottom"
HorizontalAlignment="Right" VerticalAlignment="Top">
@ -13366,7 +13334,7 @@ $inputXML = '<Window x:Class="WinUtility.MainWindow"
</Popup>
<Button
Grid.Column="2"
Grid.Column="3"
Content="&#xD7;" BorderThickness="0"
BorderBrush="Transparent"
Background="{MainBackgroundColor}"