Portable Tool for an Ideal Windows Setup
C# activatorbloatware-removalcsharpdebloatdebloaterdisable-servicesmonitoring-systemportableprivacy-toolsregistry-tweakssystem-tuningsystem-utilitytelemetrytweakerwindows-10windows-11windows-debloatwindows-defenderwindows-optimizationwindows-tweaks
-refactoring & correction
Greedeks3af876bf313c
diff --git a/.Source/GTweak/App.xaml.cs b/.Source/GTweak/App.xaml.csindex 9cebf412..760b4ce6 100644--- a/.Source/GTweak/App.xaml.cs+++ b/.Source/GTweak/App.xaml.cs@@ -1,4 +1,4 @@-using Microsoft.Win32;+using GTweak.Utilities.Helpers;using System;using System.Globalization;using System.Linq;@@ -24,8 +24,8 @@ namespace GTweakinternal static void ViewingSettings(){- Language = Registry.CurrentUser.OpenSubKey(@"Software\GTweak")?.GetValue("Language")?.ToString() ?? GettingSystemLanguage;- Theme = Registry.CurrentUser.OpenSubKey(@"Software\GTweak")?.GetValue("Theme")?.ToString() ?? "Dark";+ Language = RegistryHelp.GetValue(@"HKEY_CURRENT_USER\Software\GTweak", "Language", GettingSystemLanguage);+ Theme = RegistryHelp.GetValue(@"HKEY_CURRENT_USER\Software\GTweak", "Theme", "Dark");}internal static string Language@@ -71,7 +71,7 @@ namespace GTweak{"Light" => new Uri($"Styles/Themes/Light/Colors.xaml", UriKind.Relative),"Dark" => new Uri($"Styles/Themes/Dark/Colors.xaml", UriKind.Relative),- _ => Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Themes\Personalize")?.GetValue("AppsUseLightTheme")?.ToString()! == "0" ? new Uri("Styles/Themes/Dark/Colors.xaml", UriKind.Relative) : new Uri($"Styles/Themes/Light/Colors.xaml", UriKind.Relative),+ _ => RegistryHelp.GetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize", "AppsUseLightTheme", string.Empty) == "0" ? new Uri("Styles/Themes/Dark/Colors.xaml", UriKind.Relative) : new Uri($"Styles/Themes/Light/Colors.xaml", UriKind.Relative),}};diff --git a/.Source/GTweak/Utilities/Helpers/RegistryHelp.cs b/.Source/GTweak/Utilities/Helpers/RegistryHelp.csindex 75c21444..483b3c0d 100644--- a/.Source/GTweak/Utilities/Helpers/RegistryHelp.cs+++ b/.Source/GTweak/Utilities/Helpers/RegistryHelp.cs@@ -110,5 +110,17 @@ namespace GTweak.Utilities.Helpersreturn string.Concat((byte[])Registry.GetValue(subkey, valueName, null) ?? Array.Empty<byte>()) != expectedValue;}++ internal static T GetValue<T>(string subKey, string valueName, T defaultValue)+ {+ try+ {+ return (T)Convert.ChangeType(Registry.GetValue(subKey, valueName, defaultValue), typeof(T));+ }+ catch+ {+ return defaultValue;+ }+ }}}diff --git a/.Source/GTweak/Utilities/Helpers/TaskSchedulerManager.cs b/.Source/GTweak/Utilities/Helpers/TaskSchedulerManager.csindex 75de3446..dcafc33b 100644--- a/.Source/GTweak/Utilities/Helpers/TaskSchedulerManager.cs+++ b/.Source/GTweak/Utilities/Helpers/TaskSchedulerManager.cs@@ -47,7 +47,6 @@ namespace GTweak.Utilities.Helpersstring command = "cmd.exe /c ";foreach (string task in tasklist)command += $"schtasks /change {(state ? "/enable" : "/disable")} /tn \"{task}\" & ";-command = command.TrimEnd(' ', '&');TrustedInstaller.CreateProcessAsTrustedInstaller(SettingsRepository.PID, command);diff --git a/.Source/GTweak/Utilities/Helpers/TaskStorage.cs b/.Source/GTweak/Utilities/Helpers/TaskStorage.csindex baa87e11..bd93a167 100644--- a/.Source/GTweak/Utilities/Helpers/TaskStorage.cs+++ b/.Source/GTweak/Utilities/Helpers/TaskStorage.cs@@ -2,7 +2,7 @@{internal class TaskStorage{- internal static readonly string[] schedulerTasks = {+ internal static readonly string[] dataCollectTasks = {@"Microsoft\Windows\Maintenance\WinSAT",@"Microsoft\Windows\Autochk\Proxy",@"Microsoft\Windows\Application Experience\Microsoft Compatibility Appraiser",@@ -14,7 +14,7 @@@"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"};+ @"Microsoft\Windows\DiskDiagnostic\Microsoft-Windows-DiskDiagnosticDataCollector" };internal static readonly string[] nvidiaTasks = {@"NvTmRepOnLogon_{B2FE1952-0186-46C3-BAEC-A80AA35AC5B8}",@@ -33,7 +33,7 @@internal static readonly string[] memoryDiagTasks = {@"Microsoft\Windows\MemoryDiagnostic\ProcessMemoryDiagnosticEvents",- @"Microsoft\Windows\MemoryDiagnostic\RunFullMemoryDiagnostic"};+ @"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 cbc49f5e..29f5d5c0 100644--- a/.Source/GTweak/Utilities/Tweaks/ConfidentialityTweaks.cs+++ b/.Source/GTweak/Utilities/Tweaks/ConfidentialityTweaks.cs@@ -32,7 +32,7 @@ namespace GTweak.Utilities.TweaksRegistryHelp.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") || IsTaskEnabled(telemetryTasks);- confidentialityV.TglButton4.StateNA = IsTaskEnabled(schedulerTasks);+ confidentialityV.TglButton4.StateNA = IsTaskEnabled(dataCollectTasks);confidentialityV.TglButton5.StateNA =RegistryHelp.CheckValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\AppCompat", "DisableInventory", "1");@@ -162,7 +162,7 @@ namespace GTweak.Utilities.TweaksSetTaskState(!isChoose, telemetryTasks);break;case "TglButton4":- SetTaskState(!isChoose, schedulerTasks);+ SetTaskState(!isChoose, dataCollectTasks);break;case "TglButton5":if (isChoose)diff --git a/.Source/GTweak/Utilities/Tweaks/SystemMaintenance.cs b/.Source/GTweak/Utilities/Tweaks/SystemMaintenance.csindex 3bc5627e..b9685a7c 100644--- a/.Source/GTweak/Utilities/Tweaks/SystemMaintenance.cs+++ b/.Source/GTweak/Utilities/Tweaks/SystemMaintenance.cs@@ -33,10 +33,10 @@ namespace GTweak.Utilities.Tweaksnew ViewNotification(300).Show("", "info", (string)Application.Current.Resources["success_defrag_notification"]);}- catch { new ViewNotification(300).Show("", "warn", (string)Application.Current.Resources["error_defrag_notification"]); }+ catch { new ViewNotification().Show("", "warn", (string)Application.Current.Resources["error_defrag_notification"]); }}else- new ViewNotification(300).Show("", "info", (string)Application.Current.Resources["warn_defrag_notification"]);+ new ViewNotification().Show("", "info", (string)Application.Current.Resources["warn_defrag_notification"]);}internal static void CreateRestorePoint()@@ -73,7 +73,7 @@ namespace GTweak.Utilities.Tweakscatch{isWorkingCreatePoint = false;- new ViewNotification(300).Show("", "warn", (string)Application.Current.Resources["notsuccessfulpoint_notification"]);+ new ViewNotification().Show("", "warn", (string)Application.Current.Resources["notsuccessfulpoint_notification"]);}}diff --git a/.Source/GTweak/Utilities/Tweaks/SystemTweaks.cs b/.Source/GTweak/Utilities/Tweaks/SystemTweaks.csindex 4e74e58b..0d6423ec 100644--- a/.Source/GTweak/Utilities/Tweaks/SystemTweaks.cs+++ b/.Source/GTweak/Utilities/Tweaks/SystemTweaks.cs@@ -26,15 +26,15 @@ namespace GTweak.Utilities.Tweaks{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();+ private readonly string activeGuid = RegistryHelp.GetValue(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\User\PowerSchemes", "ActivePowerScheme", string.Empty);internal void AnalyzeAndUpdate(SystemView systemV){- systemV.Slider1.Value = Convert.ToDouble(Registry.GetValue(@"HKEY_CURRENT_USER\Control Panel\Mouse", "MouseSensitivity", "10").ToString());+ systemV.Slider1.Value = RegistryHelp.GetValue<double>(@"HKEY_CURRENT_USER\Control Panel\Mouse", "MouseSensitivity", 10);- systemV.Slider2.Value = Convert.ToDouble(Registry.GetValue(@"HKEY_CURRENT_USER\Control Panel\Keyboard", "KeyboardDelay", "1").ToString());+ systemV.Slider2.Value = RegistryHelp.GetValue<double>(@"HKEY_CURRENT_USER\Control Panel\Keyboard", "KeyboardDelay", 1);- systemV.Slider3.Value = Convert.ToDouble(Registry.GetValue(@"HKEY_CURRENT_USER\Control Panel\Keyboard", "KeyboardSpeed", "31").ToString());+ systemV.Slider3.Value = RegistryHelp.GetValue<double>(@"HKEY_CURRENT_USER\Control Panel\Keyboard", "KeyboardSpeed", 31);systemV.TglButton1.StateNA =RegistryHelp.CheckValue(@"HKEY_CURRENT_USER\Control Panel\Mouse", "MouseSpeed", "0") ||