mirror of
https://github.com/ChrisTitusTech/winutil
synced 2026-06-04 14:17:27 +00:00
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:
@@ -380,13 +380,6 @@ Update UI
|
||||
"Value": "0",
|
||||
"OriginalValue": "1"
|
||||
}
|
||||
],
|
||||
"ScheduledTask": [
|
||||
{
|
||||
"Name": "Microsoft\\Windows\\Autochk\\Proxy",
|
||||
"State": "Disabled",
|
||||
"OriginalState": "Enabled"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -397,7 +390,6 @@ Update UI
|
||||
- `Description`: What it does
|
||||
- `category`: Essential/Advanced/Customize
|
||||
- `registry`: Registry changes to make
|
||||
- `ScheduledTask`: Scheduled tasks to modify
|
||||
- `service`: Services to change
|
||||
- `OriginalValue/State`: For undo functionality
|
||||
|
||||
|
||||
@@ -44,21 +44,18 @@ Function Invoke-WinUtilCurrentSystem {
|
||||
if ($CheckBox -eq "tweaks") {
|
||||
|
||||
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 {
|
||||
|
||||
$Config = $psitem.Name
|
||||
#WPFEssTweaksTele
|
||||
$entry = $sync.configs.tweaks.$Config
|
||||
$registryKeys = $entry.registry
|
||||
$scheduledtaskKeys = $entry.scheduledtask
|
||||
$serviceKeys = $entry.service
|
||||
$appxKeys = $entry.appx
|
||||
$invokeScript = $entry.InvokeScript
|
||||
$entryType = $entry.Type
|
||||
|
||||
if ($registryKeys -or $scheduledtaskKeys -or $serviceKeys) {
|
||||
if ($registryKeys -or $serviceKeys) {
|
||||
$Values = @()
|
||||
|
||||
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 ($tweak in $tweaks) {
|
||||
$Service = Get-Service -Name $tweak.Name
|
||||
|
||||
@@ -25,7 +25,6 @@ function Invoke-WinUtilTweaks {
|
||||
if($undo) {
|
||||
$Values = @{
|
||||
Registry = "OriginalValue"
|
||||
ScheduledTask = "OriginalState"
|
||||
Service = "OriginalType"
|
||||
ScriptType = "UndoScript"
|
||||
}
|
||||
@@ -33,18 +32,11 @@ function Invoke-WinUtilTweaks {
|
||||
} else {
|
||||
$Values = @{
|
||||
Registry = "Value"
|
||||
ScheduledTask = "State"
|
||||
Service = "StartupType"
|
||||
OriginalService = "OriginalType"
|
||||
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) {
|
||||
Write-Debug "KeepServiceStartup is $KeepServiceStartup"
|
||||
$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
|
||||
}
|
||||
}
|
||||
@@ -65,10 +65,6 @@ Describe "Config Files" -ForEach @(
|
||||
@{
|
||||
name = "service"
|
||||
value = "OriginalType"
|
||||
},
|
||||
@{
|
||||
name = "ScheduledTask"
|
||||
value = "OriginalState"
|
||||
}
|
||||
)
|
||||
Foreach ($original in $Originals) {
|
||||
|
||||
Reference in New Issue
Block a user