mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2026-10-08 11:39:10 +11:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
07ccd8e2e7 | ||
|
|
9c87c02fdb |
@@ -78,7 +78,7 @@ See https://github.com/ChrisTitusTech/winutil/blob/main/.github/CONTRIBUTING.md
|
|||||||
|
|
||||||
These are the sponsors that help keep this project alive with monthly contributions.
|
These are the sponsors that help keep this project alive with monthly contributions.
|
||||||
|
|
||||||
<!-- sponsors --><a href="https://github.com/dwelfusius"><img src="https://github.com/dwelfusius.png" width="60px" alt="User avatar: " /></a><a href="https://github.com/mews-se"><img src="https://github.com/mews-se.png" width="60px" alt="User avatar: Martin" /></a><a href="https://github.com/jdiegmueller"><img src="https://github.com/jdiegmueller.png" width="60px" alt="User avatar: Jason A. Diegmueller" /></a><a href="https://github.com/robertsandrock"><img src="https://github.com/robertsandrock.png" width="60px" alt="User avatar: RMS" /></a><a href="https://github.com/paulsheets"><img src="https://github.com/paulsheets.png" width="60px" alt="User avatar: Paul" /></a><a href="https://github.com/djones369"><img src="https://github.com/djones369.png" width="60px" alt="User avatar: Dave J (WhamGeek)" /></a><a href="https://github.com/anthonymendez"><img src="https://github.com/anthonymendez.png" width="60px" alt="User avatar: Anthony Mendez" /></a><a href="https://github.com/FatBastard0"><img src="https://github.com/FatBastard0.png" width="60px" alt="User avatar: " /></a><a href="https://github.com/DursleyGuy"><img src="https://github.com/DursleyGuy.png" width="60px" alt="User avatar: DursleyGuy" /></a><a href="https://github.com/DwayneTheRockLobster1"><img src="https://github.com/DwayneTheRockLobster1.png" width="60px" alt="User avatar: " /></a><a href="https://github.com/KieraKujisawa"><img src="https://github.com/KieraKujisawa.png" width="60px" alt="User avatar: Kiera Meredith" /></a><a href="https://github.com/seanh1995"><img src="https://github.com/seanh1995.png" width="60px" alt="User avatar: Sean (ANGRYxScotsman)" /></a><a href="https://github.com/F-L-Perez"><img src="https://github.com/F-L-Perez.png" width="60px" alt="User avatar: Fra · ppe" /></a><a href="https://github.com/josencarnacao"><img src="https://github.com/josencarnacao.png" width="60px" alt="User avatar: José Encarnação" /></a><!-- sponsors -->
|
<!-- sponsors --><a href="https://github.com/dwelfusius"><img src="https://github.com/dwelfusius.png" width="60px" alt="User avatar: " /></a><a href="https://github.com/mews-se"><img src="https://github.com/mews-se.png" width="60px" alt="User avatar: Martin" /></a><a href="https://github.com/jdiegmueller"><img src="https://github.com/jdiegmueller.png" width="60px" alt="User avatar: Jason A. Diegmueller" /></a><a href="https://github.com/robertsandrock"><img src="https://github.com/robertsandrock.png" width="60px" alt="User avatar: RMS" /></a><a href="https://github.com/paulsheets"><img src="https://github.com/paulsheets.png" width="60px" alt="User avatar: Paul" /></a><a href="https://github.com/djones369"><img src="https://github.com/djones369.png" width="60px" alt="User avatar: Dave J (WhamGeek)" /></a><a href="https://github.com/anthonymendez"><img src="https://github.com/anthonymendez.png" width="60px" alt="User avatar: Anthony Mendez" /></a><a href="https://github.com/FatBastard0"><img src="https://github.com/FatBastard0.png" width="60px" alt="User avatar: " /></a><a href="https://github.com/DursleyGuy"><img src="https://github.com/DursleyGuy.png" width="60px" alt="User avatar: DursleyGuy" /></a><a href="https://github.com/DwayneTheRockLobster1"><img src="https://github.com/DwayneTheRockLobster1.png" width="60px" alt="User avatar: " /></a><a href="https://github.com/KieraKujisawa"><img src="https://github.com/KieraKujisawa.png" width="60px" alt="User avatar: Kiera Meredith" /></a><a href="https://github.com/seanh1995"><img src="https://github.com/seanh1995.png" width="60px" alt="User avatar: Sean (ANGRYxScotsman)" /></a><a href="https://github.com/josencarnacao"><img src="https://github.com/josencarnacao.png" width="60px" alt="User avatar: José Encarnação" /></a><!-- sponsors -->
|
||||||
|
|
||||||
*<sub>Sponsors with a recurring subscription also get access to the .NET alternative.</sub>
|
*<sub>Sponsors with a recurring subscription also get access to the .NET alternative.</sub>
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,8 @@ Use the quick-selection buttons at the top of the Tweaks tab to speed up setup:
|
|||||||
To see what each preset includes, view [preset.json](https://github.com/ChrisTitusTech/winutil/blob/main/config/preset.json).
|
To see what each preset includes, view [preset.json](https://github.com/ChrisTitusTech/winutil/blob/main/config/preset.json).
|
||||||
:::
|
:::
|
||||||
|
|
||||||
|
When a listed service does not exist, WinUtil logs a warning and skips it. The remaining services and tweaks still run.
|
||||||
|
|
||||||
:::caution
|
:::caution
|
||||||
Some tweaks take effect immediately, while others may require Explorer to restart, a sign-out, or a full reboot.
|
Some tweaks take effect immediately, while others may require Explorer to restart, a sign-out, or a full reboot.
|
||||||
:::
|
:::
|
||||||
|
|||||||
@@ -48,14 +48,21 @@ function Invoke-WinUtilTweaks {
|
|||||||
|
|
||||||
# The check for !($undo) is required, without it the script will throw an error for accessing unavailable member, which's the 'OriginalService' Property
|
# 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)) {
|
if ($KeepServiceStartup -AND !($undo)) {
|
||||||
|
$serviceName = $psitem.Name
|
||||||
try {
|
try {
|
||||||
# Check if the service exists
|
# Check if the service exists
|
||||||
$service = Get-Service -Name $psitem.Name -ErrorAction Stop
|
$service = Get-Service -Name $serviceName -ErrorAction Stop
|
||||||
if(!($service.StartType.ToString() -eq $psitem.$($values.OriginalService))) {
|
if(!($service.StartType.ToString() -eq $psitem.$($values.OriginalService))) {
|
||||||
$changeservice = $false
|
$changeservice = $false
|
||||||
}
|
}
|
||||||
} catch [System.ServiceProcess.ServiceNotFoundException] {
|
} catch {
|
||||||
Write-Warning "Service $($psitem.Name) was not found."
|
if ($_.FullyQualifiedErrorId -like "NoServiceFoundForGivenName,*") {
|
||||||
|
$changeservice = $false
|
||||||
|
Write-Warning "Service $serviceName was not found."
|
||||||
|
Write-WinUtilLog -Level "WARN" -Component "Service" -Message "Service $serviceName was not found."
|
||||||
|
} else {
|
||||||
|
throw
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -177,6 +177,67 @@ Describe "Invoke-WinUtilTweaks" {
|
|||||||
$Name -eq "DiagTrack" -and $StartupType -eq "Disabled"
|
$Name -eq "DiagTrack" -and $StartupType -eq "Disabled"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
It "skips a missing service and applies the remaining services and tweaks" {
|
||||||
|
$script:sync.configs.tweaks.WPFTweaksExample.service = @(
|
||||||
|
[pscustomobject]@{
|
||||||
|
Name = "CscService"
|
||||||
|
StartupType = "Disabled"
|
||||||
|
OriginalType = "Manual"
|
||||||
|
}
|
||||||
|
) + $script:sync.configs.tweaks.WPFTweaksExample.service
|
||||||
|
|
||||||
|
Mock Get-Service {
|
||||||
|
$exception = [Microsoft.PowerShell.Commands.ServiceCommandException]::new("Cannot find any service with service name '$Name'.")
|
||||||
|
$errorRecord = [System.Management.Automation.ErrorRecord]::new(
|
||||||
|
$exception,
|
||||||
|
"NoServiceFoundForGivenName,Microsoft.PowerShell.Commands.GetServiceCommand",
|
||||||
|
[System.Management.Automation.ErrorCategory]::ObjectNotFound,
|
||||||
|
$Name
|
||||||
|
)
|
||||||
|
throw $errorRecord
|
||||||
|
} -ParameterFilter { $Name -eq "CscService" -and $ErrorAction -eq "Stop" }
|
||||||
|
|
||||||
|
foreach ($tweak in @("WPFTweaksExample", "WPFTweaksServiceOnly")) {
|
||||||
|
Invoke-WinUtilTweaks -CheckBox $tweak
|
||||||
|
}
|
||||||
|
|
||||||
|
Should -Invoke -CommandName Write-Warning -Times 1 -Exactly -ParameterFilter {
|
||||||
|
$Message -eq "Service CscService was not found."
|
||||||
|
}
|
||||||
|
Should -Invoke -CommandName Write-WinUtilLog -Times 1 -Exactly -ParameterFilter {
|
||||||
|
$Level -eq "WARN" -and $Component -eq "Service" -and $Message -eq "Service CscService was not found."
|
||||||
|
}
|
||||||
|
Should -Invoke -CommandName Set-WinUtilService -Times 0 -Exactly -ParameterFilter {
|
||||||
|
$Name -eq "CscService"
|
||||||
|
}
|
||||||
|
Should -Invoke -CommandName Set-WinUtilService -Times 2 -Exactly -ParameterFilter {
|
||||||
|
$Name -eq "DiagTrack" -and $StartupType -eq "Disabled"
|
||||||
|
}
|
||||||
|
Should -Invoke -CommandName Invoke-WinUtilScript -Times 1 -Exactly -ParameterFilter {
|
||||||
|
$Name -eq "WPFTweaksExample"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
It "rethrows service lookup errors that do not identify a missing service" {
|
||||||
|
Mock Get-Service {
|
||||||
|
$exception = [Microsoft.PowerShell.Commands.ServiceCommandException]::new("Service lookup failed.")
|
||||||
|
$errorRecord = [System.Management.Automation.ErrorRecord]::new(
|
||||||
|
$exception,
|
||||||
|
"ServiceLookupFailed",
|
||||||
|
[System.Management.Automation.ErrorCategory]::OpenError,
|
||||||
|
$Name
|
||||||
|
)
|
||||||
|
throw $errorRecord
|
||||||
|
}
|
||||||
|
|
||||||
|
{ Invoke-WinUtilTweaks -CheckBox "WPFTweaksExample" } | Should -Throw -ExpectedMessage "*Service lookup failed.*"
|
||||||
|
|
||||||
|
Should -Invoke -CommandName Set-WinUtilService -Times 0 -Exactly
|
||||||
|
Should -Invoke -CommandName Set-WinUtilRegistry -Times 0 -Exactly
|
||||||
|
Should -Invoke -CommandName Invoke-WinUtilScript -Times 0 -Exactly
|
||||||
|
Should -Invoke -CommandName Write-Warning -Times 0 -Exactly
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Describe "Invoke-WinUtilTweaks completion status" {
|
Describe "Invoke-WinUtilTweaks completion status" {
|
||||||
|
|||||||
Reference in New Issue
Block a user