Portable Tool for an Ideal Windows Setup
C# activatorbloatware-removalcsharpdebloatdebloaterdisable-servicesmonitoring-systemportableprivacy-toolsregistry-tweakssystem-tuningsystem-utilitytelemetrytweakerwindows-10windows-11windows-debloatwindows-defenderwindows-optimizationwindows-tweaks
-managed tasks
Greedeks77540c26c69f
diff --git a/.Source/GTweak/GTweak.csproj b/.Source/GTweak/GTweak.csprojindex 7c40d7f7..61af1163 100644--- a/.Source/GTweak/GTweak.csproj+++ b/.Source/GTweak/GTweak.csproj@@ -285,6 +285,7 @@<Compile Include="Utilities\Tweaks\ServicesTweaks.cs" /><Compile Include="Utilities\Tweaks\SystemMaintenance.cs" /><Compile Include="Utilities\Tweaks\SystemTweaks.cs" />+ <Compile Include="Utilities\Helpers\TaskStorage.cs" /><Compile Include="Utilities\Tweaks\UninstallingPakages.cs" /><Compile Include="Utilities\Tweaks\WindowsDefender.cs" /><Compile Include="Utilities\Tweaks\WindowsLicense.cs" />diff --git a/.Source/GTweak/Utilities/Helpers/TaskSchedulerManager.cs b/.Source/GTweak/Utilities/Helpers/TaskSchedulerManager.csindex c64e755b..75de3446 100644--- a/.Source/GTweak/Utilities/Helpers/TaskSchedulerManager.cs+++ b/.Source/GTweak/Utilities/Helpers/TaskSchedulerManager.cs@@ -4,9 +4,9 @@ using System.Threading.Tasks;namespace GTweak.Utilities.Helpers{- internal class TaskSchedulerManager+ internal class TaskSchedulerManager : TaskStorage{- internal bool IsTaskEnabled(in string[] tasklist)+ internal static bool IsTaskEnabled(params string[] tasklist){byte numberRunningTask = 0;using (Microsoft.Win32.TaskScheduler.TaskService taskService = new Microsoft.Win32.TaskScheduler.TaskService())@@ -20,7 +20,7 @@ namespace GTweak.Utilities.Helpersreturn numberRunningTask > 0;}- internal static void SetTaskState(string[] tasklist, bool state)+ internal static void SetTaskState(bool state, params string[] tasklist){Task.Run(delegate{@@ -40,7 +40,7 @@ namespace GTweak.Utilities.Helpers});}- internal static void SetTaskStateOwner(string[] tasklist, bool state)+ internal static void SetTaskStateOwner(bool state, params string[] tasklist){Task.Run(delegate{diff --git a/.Source/GTweak/Utilities/Helpers/TaskStorage.cs b/.Source/GTweak/Utilities/Helpers/TaskStorage.csnew file mode 100644index 00000000..baa87e11--- /dev/null+++ b/.Source/GTweak/Utilities/Helpers/TaskStorage.cs@@ -0,0 +1,41 @@+namespace GTweak.Utilities.Helpers+{+ internal class TaskStorage+ {+ internal static readonly string[] schedulerTasks = {+ @"Microsoft\Windows\Maintenance\WinSAT",+ @"Microsoft\Windows\Autochk\Proxy",+ @"Microsoft\Windows\Application Experience\Microsoft Compatibility Appraiser",+ @"Microsoft\Windows\Application Experience\ProgramDataUpdater",+ @"Microsoft\Windows\Application Experience\StartupAppTask",+ @"Microsoft\Windows\PI\Sqm-Tasks",+ @"Microsoft\Windows\NetTrace\GatherNetworkInfo",+ @"Microsoft\Windows\Customer Experience Improvement Program\Consolidator",+ @"Microsoft\Windows\Customer Experience Improvement Program\KernelCeipTask",+ @"Microsoft\Windows\Customer Experience Improvement Program\UsbCeip",+ @"Microsoft\Windows\DiskDiagnostic\Microsoft-Windows-DiskDiagnosticResolver",+ @"Microsoft\Windows\DiskDiagnostic\Microsoft-Windows-DiskDiagnosticDataCollector"};++ internal static readonly string[] nvidiaTasks = {+ @"NvTmRepOnLogon_{B2FE1952-0186-46C3-BAEC-A80AA35AC5B8}",+ @"NvTmRep_{B2FE1952-0186-46C3-BAEC-A80AA35AC5B8}",+ @"NvTmMon_{B2FE1952-0186-46C3-BAEC-A80AA35AC5B8}" };++ internal static readonly string[] telemetryTasks = {+ @"Microsoft\Office\Office ClickToRun Service Monitor",+ @"Microsoft\Office\OfficeTelemetry\AgentFallBack2016",+ @"Microsoft\Office\OfficeTelemetry\OfficeTelemetryAgentLogOn2016",+ @"Microsoft\Office\OfficeTelemetryAgentFallBack2016",+ @"Microsoft\Office\OfficeTelemetryAgentLogOn2016",+ @"Microsoft\Office\OfficeTelemetryAgentFallBack",+ @"Microsoft\Office\OfficeTelemetryAgentLogOn",+ @"Microsoft\Office\Office 15 Subscription Heartbeat" };++ internal static readonly string[] memoryDiagTasks = {+ @"Microsoft\Windows\MemoryDiagnostic\ProcessMemoryDiagnosticEvents",+ @"Microsoft\Windows\MemoryDiagnostic\RunFullMemoryDiagnostic"};++ internal static readonly string restoreTask = @"Microsoft\Windows\SystemRestore\SR";+ internal static readonly string defragTask = @"Microsoft\Windows\Defrag\ScheduledDefrag";+ }+}diff --git a/.Source/GTweak/Utilities/Tweaks/ConfidentialityTweaks.cs b/.Source/GTweak/Utilities/Tweaks/ConfidentialityTweaks.csindex 19889eed..cbc49f5e 100644--- a/.Source/GTweak/Utilities/Tweaks/ConfidentialityTweaks.cs+++ b/.Source/GTweak/Utilities/Tweaks/ConfidentialityTweaks.cs@@ -14,35 +14,6 @@ namespace GTweak.Utilities.Tweaks{internal sealed class ConfidentialityTweaks : Firewall{- private static readonly string[] SchedulerTasks = {- @"Microsoft\Windows\Maintenance\WinSAT",- @"Microsoft\Windows\Autochk\Proxy",- @"Microsoft\Windows\Application Experience\Microsoft Compatibility Appraiser",- @"Microsoft\Windows\Application Experience\ProgramDataUpdater",- @"Microsoft\Windows\Application Experience\StartupAppTask",- @"Microsoft\Windows\PI\Sqm-Tasks",- @"Microsoft\Windows\NetTrace\GatherNetworkInfo",- @"Microsoft\Windows\Customer Experience Improvement Program\Consolidator",- @"Microsoft\Windows\Customer Experience Improvement Program\KernelCeipTask",- @"Microsoft\Windows\Customer Experience Improvement Program\UsbCeip",- @"Microsoft\Windows\DiskDiagnostic\Microsoft-Windows-DiskDiagnosticResolver",- @"Microsoft\Windows\DiskDiagnostic\Microsoft-Windows-DiskDiagnosticDataCollector"};-- private static readonly string[] NvidiaTasks = {- @"NvTmRepOnLogon_{B2FE1952-0186-46C3-BAEC-A80AA35AC5B8}",- @"NvTmRep_{B2FE1952-0186-46C3-BAEC-A80AA35AC5B8}",- @"NvTmMon_{B2FE1952-0186-46C3-BAEC-A80AA35AC5B8}" };-- private static readonly string[] TelemetryTasks = {- @"Microsoft\Office\Office ClickToRun Service Monitor",- @"Microsoft\Office\OfficeTelemetry\AgentFallBack2016",- @"Microsoft\Office\OfficeTelemetry\OfficeTelemetryAgentLogOn2016",- @"Microsoft\Office\OfficeTelemetryAgentFallBack2016",- @"Microsoft\Office\OfficeTelemetryAgentLogOn2016",- @"Microsoft\Office\OfficeTelemetryAgentFallBack",- @"Microsoft\Office\OfficeTelemetryAgentLogOn",- @"Microsoft\Office\Office 15 Subscription Heartbeat" };-internal void AnalyzeAndUpdate(ConfidentialityView confidentialityV){confidentialityV.TglButton1.StateNA =@@ -59,9 +30,9 @@ namespace GTweak.Utilities.TweaksconfidentialityV.TglButton3.StateNA =RegistryHelp.CheckValue(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\WMI\Autologger\Diagtrack-Listener", "Start", "0") ||- RegistryHelp.CheckValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Attachments", "SaveZoneInformation", "1");+ RegistryHelp.CheckValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Attachments", "SaveZoneInformation", "1") || IsTaskEnabled(telemetryTasks);- confidentialityV.TglButton4.StateNA = IsTaskEnabled(SchedulerTasks);+ confidentialityV.TglButton4.StateNA = IsTaskEnabled(schedulerTasks);confidentialityV.TglButton5.StateNA =RegistryHelp.CheckValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\AppCompat", "DisableInventory", "1");@@ -109,7 +80,7 @@ namespace GTweak.Utilities.TweaksRegistryHelp.CheckValue(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\diagnosticshub.standardcollector.service", "Start", "4");confidentialityV.TglButton17.StateNA = SystemDiagnostics.HardwareData["GPU"].ToLower().Contains("nvidia")- && (RegistryHelp.CheckValue(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\NvTelemetryContainer", "Start", "4") || IsTaskEnabled(NvidiaTasks));+ && (RegistryHelp.CheckValue(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\NvTelemetryContainer", "Start", "4") || IsTaskEnabled(nvidiaTasks));confidentialityV.TglButton18.StateNA =RegistryHelp.CheckValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\AppCompat", "DisableUAR", "1") ||@@ -188,10 +159,10 @@ namespace GTweak.Utilities.TweakselseRegistryHelp.DeleteValue(Registry.CurrentUser, @"SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Attachments", "SaveZoneInformation");- SetTaskState(TelemetryTasks, !isChoose);+ SetTaskState(!isChoose, telemetryTasks);break;case "TglButton4":- SetTaskState(SchedulerTasks, !isChoose);+ SetTaskState(!isChoose, schedulerTasks);break;case "TglButton5":if (isChoose)@@ -314,7 +285,7 @@ namespace GTweak.Utilities.Tweaksbreak;case "TglButton17":RegistryHelp.Write(Registry.LocalMachine, @"SYSTEM\CurrentControlSet\Services\NvTelemetryContainer", "Start", isChoose ? 4 : 2, RegistryValueKind.DWord);- SetTaskState(NvidiaTasks, !isChoose);+ SetTaskState(!isChoose, nvidiaTasks);break;case "TglButton18":if (isChoose)diff --git a/.Source/GTweak/Utilities/Tweaks/ServicesTweaks.cs b/.Source/GTweak/Utilities/Tweaks/ServicesTweaks.csindex 1273f6fd..3df78efb 100644--- a/.Source/GTweak/Utilities/Tweaks/ServicesTweaks.cs+++ b/.Source/GTweak/Utilities/Tweaks/ServicesTweaks.cs@@ -446,10 +446,10 @@ namespace GTweak.Utilities.TweaksDirectory.Delete(cachePath, true);}- SetTaskStateOwner(WinUpdateTasks, false);+ SetTaskStateOwner(false, WinUpdateTasks);}else- SetTaskStateOwner(WinUpdateTasks, true);+ SetTaskStateOwner(true, WinUpdateTasks);}catch (Exception ex) { Debug.WriteLine(ex); }});diff --git a/.Source/GTweak/Utilities/Tweaks/SystemMaintenance.cs b/.Source/GTweak/Utilities/Tweaks/SystemMaintenance.csindex e450095d..3bc5627e 100644--- a/.Source/GTweak/Utilities/Tweaks/SystemMaintenance.cs+++ b/.Source/GTweak/Utilities/Tweaks/SystemMaintenance.cs@@ -18,18 +18,16 @@ namespace GTweak.Utilities.Tweaksprivate static readonly ManagementClass RestorePoint = new ManagementClass(new ManagementScope(@"\\localhost\root\default"), new ManagementPath("SystemRestore"), new ObjectGetOptions());private static ManagementBaseObject InParams, OutParams;private static bool isWorkingCreatePoint = false;- private static readonly string[] RestoreTask = { @"Microsoft\Windows\SystemRestore\SR" };- private readonly string[] DefragTask = { @"Microsoft\Windows\Defrag\ScheduledDefrag" };internal static bool IsSystemRestoreDisabled => RegistryHelp.CheckValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SystemRestore", "RPSessionInterval", "0");- internal void DisableDefrag()+ internal static void DisableDefrag(){- if (IsTaskEnabled(DefragTask))+ if (IsTaskEnabled(defragTask)){try{- SetTaskStateOwner(DefragTask, false);+ SetTaskStateOwner(false, defragTask);RegistryHelp.Write(Registry.LocalMachine, @"SYSTEM\CurrentControlSet\services\defragsvc", "Start", 4, RegistryValueKind.DWord);RegistryHelp.Write(Registry.LocalMachine, @"SOFTWARE\Microsoft\Dfrg\BootOptimizeFunction", "Enable", "N", RegistryValueKind.String);@@ -100,7 +98,7 @@ namespace GTweak.Utilities.Tweaks{if (IsSystemRestoreDisabled){- SetTaskState(RestoreTask, false);+ SetTaskState(false, restoreTask);Process.Start(new ProcessStartInfo(){@@ -125,7 +123,7 @@ namespace GTweak.Utilities.Tweaks{RegistryHelp.DeleteFolderTree(Registry.LocalMachine, @"SOFTWARE\Policies\Microsoft\Windows NT\SystemRestore");- SetTaskState(RestoreTask, true);+ SetTaskState(true, restoreTask);Process.Start(new ProcessStartInfo(){diff --git a/.Source/GTweak/Utilities/Tweaks/SystemTweaks.cs b/.Source/GTweak/Utilities/Tweaks/SystemTweaks.csindex b4dec233..4e74e58b 100644--- a/.Source/GTweak/Utilities/Tweaks/SystemTweaks.cs+++ b/.Source/GTweak/Utilities/Tweaks/SystemTweaks.cs@@ -24,10 +24,6 @@ namespace GTweak.Utilities.Tweaksinternal sealed class SystemTweaks : Firewall{- private static readonly string[] schedulerTasks = new string[2] {- @"Microsoft\Windows\MemoryDiagnostic\ProcessMemoryDiagnosticEvents",- @"Microsoft\Windows\MemoryDiagnostic\RunFullMemoryDiagnostic"};-internal static bool isTweakWorkingAntivirus = false;private static bool isNetshState = false, isBluetoothStatus = false;private readonly string activeGuid = Registry.GetValue(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\User\PowerSchemes", "ActivePowerScheme", string.Empty).ToString();@@ -110,7 +106,7 @@ namespace GTweak.Utilities.TweaksRegistryHelp.CheckValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Security", "DisableSecuritySettingsCheck", "1") ||RegistryHelp.CheckValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3", "1806", "0");- systemV.TglButton12.StateNA = IsTaskEnabled(schedulerTasks);+ systemV.TglButton12.StateNA = IsTaskEnabled(memoryDiagTasks);systemV.TglButton13.StateNA = isNetshState;@@ -297,7 +293,7 @@ namespace GTweak.Utilities.Tweaks}break;case "TglButton12":- SetTaskState(schedulerTasks, !isChoose);+ SetTaskState(!isChoose, memoryDiagTasks);break;case "TglButton13":string argStateNetsh = string.Empty, argStateNetshSecond = string.Empty;diff --git a/.Source/GTweak/View/MoreView.xaml.cs b/.Source/GTweak/View/MoreView.xaml.csindex 0cf0a2b5..275aeadf 100644--- a/.Source/GTweak/View/MoreView.xaml.cs+++ b/.Source/GTweak/View/MoreView.xaml.cs@@ -36,7 +36,7 @@ namespace GTweak.Viewprivate void BtnClear_ClickButton(object sender, EventArgs e) => new ClearingMemory().StartMemoryCleanup();- private void BtnDisableDefrag_ClickButton(object sender, EventArgs e) => new SystemMaintenance().DisableDefrag();+ private void BtnDisableDefrag_ClickButton(object sender, EventArgs e) => SystemMaintenance.DisableDefrag();private async void BtnDisableRecovery_ClickButton(object sender, EventArgs e){