Cleanup: Delete all Scheduled Tasks related things (#4435)

* Delete functions/private/Set-WinUtilScheduledTask.ps1

* Update Invoke-WinUtilTweaks.ps1

* Update Invoke-WinUtilCurrentSystem.ps1

* waste of time

---------

Co-authored-by: Gabi <218829269+GabiNun2@users.noreply.github.com>
This commit is contained in:
Chris Titus
2026-04-30 15:16:27 -05:00
committed by GitHub
parent 9d4613d838
commit 184fe22a35
5 changed files with 1 additions and 80 deletions
-8
View File
@@ -380,13 +380,6 @@ Update UI
"Value": "0", "Value": "0",
"OriginalValue": "1" "OriginalValue": "1"
} }
],
"ScheduledTask": [
{
"Name": "Microsoft\\Windows\\Autochk\\Proxy",
"State": "Disabled",
"OriginalState": "Enabled"
}
] ]
} }
} }
@@ -397,7 +390,6 @@ Update UI
- `Description`: What it does - `Description`: What it does
- `category`: Essential/Advanced/Customize - `category`: Essential/Advanced/Customize
- `registry`: Registry changes to make - `registry`: Registry changes to make
- `ScheduledTask`: Scheduled tasks to modify
- `service`: Services to change - `service`: Services to change
- `OriginalValue/State`: For undo functionality - `OriginalValue/State`: For undo functionality
@@ -44,21 +44,18 @@ Function Invoke-WinUtilCurrentSystem {
if ($CheckBox -eq "tweaks") { if ($CheckBox -eq "tweaks") {
if (!(Test-Path 'HKU:\')) {$null = (New-PSDrive -PSProvider Registry -Name HKU -Root HKEY_USERS)} if (!(Test-Path 'HKU:\')) {$null = (New-PSDrive -PSProvider Registry -Name HKU -Root HKEY_USERS)}
$ScheduledTasks = Get-ScheduledTask
$sync.configs.tweaks | Get-Member -MemberType NoteProperty | ForEach-Object { $sync.configs.tweaks | Get-Member -MemberType NoteProperty | ForEach-Object {
$Config = $psitem.Name $Config = $psitem.Name
#WPFEssTweaksTele
$entry = $sync.configs.tweaks.$Config $entry = $sync.configs.tweaks.$Config
$registryKeys = $entry.registry $registryKeys = $entry.registry
$scheduledtaskKeys = $entry.scheduledtask
$serviceKeys = $entry.service $serviceKeys = $entry.service
$appxKeys = $entry.appx $appxKeys = $entry.appx
$invokeScript = $entry.InvokeScript $invokeScript = $entry.InvokeScript
$entryType = $entry.Type $entryType = $entry.Type
if ($registryKeys -or $scheduledtaskKeys -or $serviceKeys) { if ($registryKeys -or $serviceKeys) {
$Values = @() $Values = @()
if ($entryType -eq "Toggle") { if ($entryType -eq "Toggle") {
@@ -103,20 +100,6 @@ Function Invoke-WinUtilCurrentSystem {
} }
} }
Foreach ($tweaks in $scheduledtaskKeys) {
Foreach ($tweak in $tweaks) {
$task = $ScheduledTasks | Where-Object {$($psitem.TaskPath + $psitem.TaskName) -like "\$($tweak.name)"}
if ($task) {
$actualValue = $task.State
$expectedValue = $tweak.State
if ($expectedValue -ne $actualValue) {
$values += $False
}
}
}
}
Foreach ($tweaks in $serviceKeys) { Foreach ($tweaks in $serviceKeys) {
Foreach ($tweak in $tweaks) { Foreach ($tweak in $tweaks) {
$Service = Get-Service -Name $tweak.Name $Service = Get-Service -Name $tweak.Name
@@ -25,7 +25,6 @@ function Invoke-WinUtilTweaks {
if($undo) { if($undo) {
$Values = @{ $Values = @{
Registry = "OriginalValue" Registry = "OriginalValue"
ScheduledTask = "OriginalState"
Service = "OriginalType" Service = "OriginalType"
ScriptType = "UndoScript" ScriptType = "UndoScript"
} }
@@ -33,18 +32,11 @@ function Invoke-WinUtilTweaks {
} else { } else {
$Values = @{ $Values = @{
Registry = "Value" Registry = "Value"
ScheduledTask = "State"
Service = "StartupType" Service = "StartupType"
OriginalService = "OriginalType" OriginalService = "OriginalType"
ScriptType = "InvokeScript" ScriptType = "InvokeScript"
} }
} }
if($sync.configs.tweaks.$CheckBox.ScheduledTask) {
$sync.configs.tweaks.$CheckBox.ScheduledTask | ForEach-Object {
Write-Debug "$($psitem.Name) and state is $($psitem.$($values.ScheduledTask))"
Set-WinUtilScheduledTask -Name $psitem.Name -State $psitem.$($values.ScheduledTask)
}
}
if($sync.configs.tweaks.$CheckBox.service) { if($sync.configs.tweaks.$CheckBox.service) {
Write-Debug "KeepServiceStartup is $KeepServiceStartup" Write-Debug "KeepServiceStartup is $KeepServiceStartup"
$sync.configs.tweaks.$CheckBox.service | ForEach-Object { $sync.configs.tweaks.$CheckBox.service | ForEach-Object {
@@ -1,42 +0,0 @@
function Set-WinUtilScheduledTask {
<#
.SYNOPSIS
Enables/Disables the provided Scheduled Task
.PARAMETER Name
The path to the Scheduled Task
.PARAMETER State
The State to set the Task to
.EXAMPLE
Set-WinUtilScheduledTask -Name "Microsoft\Windows\Application Experience\Microsoft Compatibility Appraiser" -State "Disabled"
#>
param (
$Name,
$State
)
try {
if($State -eq "Disabled") {
Write-Host "Disabling Scheduled Task $Name"
Disable-ScheduledTask -TaskName $Name -ErrorAction Stop
}
if($State -eq "Enabled") {
Write-Host "Enabling Scheduled Task $Name"
Enable-ScheduledTask -TaskName $Name -ErrorAction Stop
}
} catch [System.Exception] {
if($psitem.Exception.Message -like "*The system cannot find the file specified*") {
Write-Warning "Scheduled Task $Name was not found."
} else {
Write-Warning "Unable to set $Name due to unhandled exception."
Write-Warning $psitem.Exception.Message
}
} catch {
Write-Warning "Unable to run script for $name due to unhandled exception."
Write-Warning $psitem.Exception.StackTrace
}
}
-4
View File
@@ -65,10 +65,6 @@ Describe "Config Files" -ForEach @(
@{ @{
name = "service" name = "service"
value = "OriginalType" value = "OriginalType"
},
@{
name = "ScheduledTask"
value = "OriginalState"
} }
) )
Foreach ($original in $Originals) { Foreach ($original in $Originals) {