mirror of
https://github.com/ChrisTitusTech/winutil
synced 2026-06-04 14:17:27 +00:00
8034e85521
* Update Invoke-WinUtilCurrentSystem.ps1 * Update Invoke-WinUtilFontScaling.ps1 * Update Invoke-WinUtilTweaks.ps1 * Update Reset-WPFCheckBoxes.ps1 * Update Set-Preferences.ps1 * Update Update-WinUtilSelections.ps1 * Update Invoke-WPFSelectedCheckboxesUpdate.ps1 * Update Invoke-WPFtweaksbutton.ps1 * Update main.ps1 * Update main.ps1 * Update main.ps1 * Update main.ps1 * Update main.ps1 * Merge branch 'main' into Remove-Write-Debug
81 lines
2.7 KiB
PowerShell
81 lines
2.7 KiB
PowerShell
function Invoke-WinUtilTweaks {
|
|
<#
|
|
|
|
.SYNOPSIS
|
|
Invokes the function associated with each provided checkbox
|
|
|
|
.PARAMETER CheckBox
|
|
The checkbox to invoke
|
|
|
|
.PARAMETER undo
|
|
Indicates whether to undo the operation contained in the checkbox
|
|
|
|
.PARAMETER KeepServiceStartup
|
|
Indicates whether to override the startup of a service with the one given from WinUtil,
|
|
or to keep the startup of said service, if it was changed by the user, or another program, from its default value.
|
|
#>
|
|
|
|
param(
|
|
$CheckBox,
|
|
$undo = $false,
|
|
$KeepServiceStartup = $true
|
|
)
|
|
|
|
if ($undo) {
|
|
$Values = @{
|
|
Registry = "OriginalValue"
|
|
Service = "OriginalType"
|
|
ScriptType = "UndoScript"
|
|
}
|
|
|
|
} else {
|
|
$Values = @{
|
|
Registry = "Value"
|
|
Service = "StartupType"
|
|
OriginalService = "OriginalType"
|
|
ScriptType = "InvokeScript"
|
|
}
|
|
}
|
|
if ($sync.configs.tweaks.$CheckBox.service) {
|
|
$sync.configs.tweaks.$CheckBox.service | ForEach-Object {
|
|
$changeservice = $true
|
|
|
|
# The check for !($undo) is required, without it the script will throw an error for accessing unavailable member, which's the 'OriginalService' Property
|
|
if ($KeepServiceStartup -AND !($undo)) {
|
|
try {
|
|
# Check if the service exists
|
|
$service = Get-Service -Name $psitem.Name -ErrorAction Stop
|
|
if(!($service.StartType.ToString() -eq $psitem.$($values.OriginalService))) {
|
|
$changeservice = $false
|
|
}
|
|
} catch [System.ServiceProcess.ServiceNotFoundException] {
|
|
Write-Warning "Service $($psitem.Name) was not found."
|
|
}
|
|
}
|
|
|
|
if ($changeservice) {
|
|
Set-WinUtilService -Name $psitem.Name -StartupType $psitem.$($values.Service)
|
|
}
|
|
}
|
|
}
|
|
if ($sync.configs.tweaks.$CheckBox.registry) {
|
|
$sync.configs.tweaks.$CheckBox.registry | ForEach-Object {
|
|
Set-WinUtilRegistry -Name $psitem.Name -Path $psitem.Path -Type $psitem.Type -Value $psitem.$($values.registry)
|
|
}
|
|
}
|
|
if ($sync.configs.tweaks.$CheckBox.$($values.ScriptType)) {
|
|
$sync.configs.tweaks.$CheckBox.$($values.ScriptType) | ForEach-Object {
|
|
$Scriptblock = [scriptblock]::Create($psitem)
|
|
Invoke-WinUtilScript -ScriptBlock $scriptblock -Name $CheckBox
|
|
}
|
|
}
|
|
|
|
if (!$undo) {
|
|
if($sync.configs.tweaks.$CheckBox.appx) {
|
|
$sync.configs.tweaks.$CheckBox.appx | ForEach-Object {
|
|
Remove-WinUtilAPPX -Name $psitem
|
|
}
|
|
}
|
|
}
|
|
}
|