Portable Tool for an Ideal Windows Setup
C# activatorbloatware-removalcsharpdebloatdebloaterdisable-servicesmonitoring-systemportableprivacy-toolsregistry-tweakssystem-tuningsystem-utilitytelemetrytweakerwindows-10windows-11windows-debloatwindows-defenderwindows-optimizationwindows-tweaks
-fixed bug (crash when null is detected in the list of power supply circuits) -refactoring (working with Firewall)
Greedeksc5f9341ebdcd
diff --git a/.Source/GTweak/Utilities/Tweaks/Firewall.cs b/.Source/GTweak/Utilities/Tweaks/Firewall.csindex 38fc35f7..566e0547 100644--- a/.Source/GTweak/Utilities/Tweaks/Firewall.cs+++ b/.Source/GTweak/Utilities/Tweaks/Firewall.cs@@ -8,13 +8,14 @@ namespace GTweak.Utilities.Tweaks{internal abstract class Firewall{- private static bool CheckRulesWindowsUpdate()+ private static readonly string nameRules = @"GTweak - Windows Update blocking";+ private static bool CheckRulesWindows(string nameRule){bool isCheck = true;INetFwPolicy2 firewallRuleCheck = (INetFwPolicy2)Activator.CreateInstance(Type.GetTypeFromProgID("HNetCfg.FwPolicy2"));foreach (INetFwRule rule in firewallRuleCheck.Rules){- if (rule.Name == "GTweak - Windows Update blocking")+ if (rule.Name == nameRule)isCheck = false;}return isCheck;@@ -22,142 +23,82 @@ namespace GTweak.Utilities.Tweaksprotected static void BlockWindowsUpdate(bool isChoose){- App.ViewLang();try{- if (CheckRulesWindowsUpdate() && isChoose)+ if (CheckRulesWindows(nameRules) && isChoose){Parallel.Invoke(- () => { RulesUpdateIN(isChoose); },- () => { RulesUpdateOUT(isChoose); });+ () => { RulesUpdateIN(isChoose, Settings.PathSystemDisk + @"Windows\UUS\amd64\MoUsoCoreWorker.exe", nameRules); },+ () => { RulesUpdateIN(isChoose, Settings.PathSystemDisk + @"Windows\System32\MoUsoCoreWorker.exe", string.Concat(nameRules," (Old Way)")); },+ () => { RulesUpdateIN(isChoose, Settings.PathSystemDisk + @"Windows\System32\usoclient.exe", string.Concat(nameRules," (Update Orchestrator)")); },+ () => { RulesUpdateOUT(isChoose, Settings.PathSystemDisk + @"Windows\UUS\amd64\MoUsoCoreWorker.exe", nameRules); },+ () => { RulesUpdateOUT(isChoose, Settings.PathSystemDisk + @"Windows\System32\MoUsoCoreWorker.exe", string.Concat(nameRules, " (Old Way)")); },+ () => { RulesUpdateOUT(isChoose, Settings.PathSystemDisk + @"Windows\System32\usoclient.exe", string.Concat(nameRules, " (Update Orchestrator)")); });}else{- try { RulesUpdateIN(isChoose); } catch (Exception ex) { Debug.WriteLine(ex.Message.ToString()); }- try { RulesUpdateOUT(isChoose); } catch (Exception ex) { Debug.WriteLine(ex.Message.ToString()); }+ try {+ RulesUpdateIN(isChoose, Settings.PathSystemDisk + @"Windows\UUS\amd64\MoUsoCoreWorker.exe", nameRules);+ RulesUpdateIN(isChoose, Settings.PathSystemDisk + @"Windows\System32\MoUsoCoreWorker.exe", string.Concat(nameRules, " (Old Way)"));+ RulesUpdateIN(isChoose, Settings.PathSystemDisk + @"Windows\System32\usoclient.exe", string.Concat(nameRules, " (Update Orchestrator)"));+ } catch (Exception ex) { Debug.WriteLine(ex.Message.ToString()); }+ try {+ RulesUpdateOUT(isChoose, Settings.PathSystemDisk + @"Windows\UUS\amd64\MoUsoCoreWorker.exe", nameRules);+ RulesUpdateOUT(isChoose, Settings.PathSystemDisk + @"Windows\System32\MoUsoCoreWorker.exe", string.Concat(nameRules, " (Old Way)"));+ RulesUpdateOUT(isChoose, Settings.PathSystemDisk + @"Windows\System32\usoclient.exe", string.Concat(nameRules, " (Update Orchestrator)"));+ } catch (Exception ex) { Debug.WriteLine(ex.Message.ToString()); }}}- catch { new ViewNotification().Show("", (string)Application.Current.Resources["title0_notification"], (string)Application.Current.Resources["firewalloff_notification"]); }+ catch+ {+ App.ViewLang();+ new ViewNotification().Show("", (string)Application.Current.Resources["title0_notification"], (string)Application.Current.Resources["firewalloff_notification"]);+ }}- private static void RulesUpdateIN(in bool isChoose)+ private static void RulesUpdateIN(in bool isChoose, in string pathProgram, in string nameRule){INetFwRule firewallRule = (INetFwRule)Activator.CreateInstance(Type.GetTypeFromProgID("HNetCfg.FWRule"));INetFwPolicy2 firewallPolicy = (INetFwPolicy2)Activator.CreateInstance(Type.GetTypeFromProgID("HNetCfg.FwPolicy2"));- firewallRule.ApplicationName = Settings.PathSystemDisk + @"Windows\UUS\amd64\MoUsoCoreWorker.exe";- firewallRule.Action = NET_FW_ACTION_.NET_FW_ACTION_BLOCK;- firewallRule.Direction = NET_FW_RULE_DIRECTION_.NET_FW_RULE_DIR_IN;- firewallRule.Description = "Windows update blocking";- firewallRule.Enabled = true;- firewallRule.InterfaceTypes = "All";- firewallRule.Name = $"GTweak - Windows Update blocking";-- if (isChoose)- {- firewallPolicy.Rules.Remove($"GTweak - Windows Update blocking");- firewallPolicy.Rules.Add(firewallRule);- }- else- firewallPolicy.Rules.Remove($"GTweak - Windows Update blocking");-- firewallRule = (INetFwRule)Activator.CreateInstance(Type.GetTypeFromProgID("HNetCfg.FWRule"));- firewallPolicy = (INetFwPolicy2)Activator.CreateInstance(Type.GetTypeFromProgID("HNetCfg.FwPolicy2"));-- firewallRule.ApplicationName = Settings.PathSystemDisk + @"Windows\System32\MoUsoCoreWorker.exe";+ firewallRule.ApplicationName = pathProgram;firewallRule.Action = NET_FW_ACTION_.NET_FW_ACTION_BLOCK;firewallRule.Direction = NET_FW_RULE_DIRECTION_.NET_FW_RULE_DIR_IN;firewallRule.Description = "Windows update blocking";firewallRule.Enabled = true;firewallRule.InterfaceTypes = "All";- firewallRule.Name = $"GTweak - Windows Update blocking (Old Way)";+ firewallRule.Name = nameRule;if (isChoose){- firewallPolicy.Rules.Remove($"GTweak - Windows Update blocking (Old Way)");+ firewallPolicy.Rules.Remove(nameRule);firewallPolicy.Rules.Add(firewallRule);}else- firewallPolicy.Rules.Remove($"GTweak - Windows Update blocking (Old Way)");-- firewallRule = (INetFwRule)Activator.CreateInstance(Type.GetTypeFromProgID("HNetCfg.FWRule"));- firewallPolicy = (INetFwPolicy2)Activator.CreateInstance(Type.GetTypeFromProgID("HNetCfg.FwPolicy2"));-- firewallRule.ApplicationName = Settings.PathSystemDisk + @"Windows\System32\usoclient.exe";- firewallRule.Action = NET_FW_ACTION_.NET_FW_ACTION_BLOCK;- firewallRule.Direction = NET_FW_RULE_DIRECTION_.NET_FW_RULE_DIR_IN;- firewallRule.Description = "Windows update blocking";- firewallRule.Enabled = true;- firewallRule.InterfaceTypes = "All";- firewallRule.Name = $"GTweak - Windows Update blocking (Update Orchestrator)";-- if (isChoose)- {- firewallPolicy.Rules.Remove($"GTweak - Windows Update blocking (Update Orchestrator)");- firewallPolicy.Rules.Add(firewallRule);- }- else- firewallPolicy.Rules.Remove($"GTweak - Windows Update blocking (Update Orchestrator)");+ firewallPolicy.Rules.Remove(nameRule);}- private static void RulesUpdateOUT(in bool isChoose)+ private static void RulesUpdateOUT(in bool isChoose, in string pathProgram, in string nameRule){INetFwRule firewallRule = (INetFwRule)Activator.CreateInstance(Type.GetTypeFromProgID("HNetCfg.FWRule"));INetFwPolicy2 firewallPolicy = (INetFwPolicy2)Activator.CreateInstance(Type.GetTypeFromProgID("HNetCfg.FwPolicy2"));- firewallRule.ApplicationName = Settings.PathSystemDisk + @"Windows\UUS\amd64\MoUsoCoreWorker.exe";+ firewallRule.ApplicationName = pathProgram;firewallRule.Action = NET_FW_ACTION_.NET_FW_ACTION_BLOCK;firewallRule.Direction = NET_FW_RULE_DIRECTION_.NET_FW_RULE_DIR_OUT;firewallRule.Description = "Windows update blocking";firewallRule.Enabled = true;firewallRule.InterfaceTypes = "All";- firewallRule.Name = $"GTweak - Windows Update blocking";+ firewallRule.Name = nameRule;if (isChoose){- firewallPolicy.Rules.Remove($"GTweak - Windows Update blocking");+ firewallPolicy.Rules.Remove(nameRule);firewallPolicy.Rules.Add(firewallRule);}else- firewallPolicy.Rules.Remove($"GTweak - Windows Update blocking");-- firewallRule = (INetFwRule)Activator.CreateInstance(Type.GetTypeFromProgID("HNetCfg.FWRule"));- firewallPolicy = (INetFwPolicy2)Activator.CreateInstance(Type.GetTypeFromProgID("HNetCfg.FwPolicy2"));-- firewallRule.ApplicationName = Settings.PathSystemDisk + @"Windows\System32\MoUsoCoreWorker.exe";- firewallRule.Action = NET_FW_ACTION_.NET_FW_ACTION_BLOCK;- firewallRule.Direction = NET_FW_RULE_DIRECTION_.NET_FW_RULE_DIR_OUT;- firewallRule.Description = "Windows update blocking";- firewallRule.Enabled = true;- firewallRule.InterfaceTypes = "All";- firewallRule.Name = $"GTweak - Windows Update blocking (Old Way)";+ firewallPolicy.Rules.Remove(nameRule);- if (isChoose)- {- firewallPolicy.Rules.Remove($"GTweak - Windows Update blocking (Old Way)");- firewallPolicy.Rules.Add(firewallRule);- }- else- firewallPolicy.Rules.Remove($"GTweak - Windows Update blocking (Old Way)");-- firewallRule = (INetFwRule)Activator.CreateInstance(Type.GetTypeFromProgID("HNetCfg.FWRule"));- firewallPolicy = (INetFwPolicy2)Activator.CreateInstance(Type.GetTypeFromProgID("HNetCfg.FwPolicy2"));-- firewallRule.ApplicationName = Settings.PathSystemDisk + @"Windows\System32\usoclient.exe";- firewallRule.Action = NET_FW_ACTION_.NET_FW_ACTION_BLOCK;- firewallRule.Direction = NET_FW_RULE_DIRECTION_.NET_FW_RULE_DIR_OUT;- firewallRule.Description = "Windows update blocking";- firewallRule.Enabled = true;- firewallRule.InterfaceTypes = "All";- firewallRule.Name = $"GTweak - Windows Update blocking (Update Orchestrator)";-- if (isChoose)- {- firewallPolicy.Rules.Remove($"GTweak - Windows Update blocking (Update Orchestrator)");- firewallPolicy.Rules.Add(firewallRule);- }- else- firewallPolicy.Rules.Remove($"GTweak - Windows Update blocking (Update Orchestrator)");}protected static void BlockSpyDomain(in bool isCheck)@@ -165,7 +106,7 @@ namespace GTweak.Utilities.TweaksApp.ViewLang();try{- if (CheckRulesWindowsUpdate() && isCheck)+ if (CheckRulesWindows(@"GTweak - Spy domain names") && isCheck)RulesHosts(isCheck);else{@@ -202,15 +143,15 @@ namespace GTweak.Utilities.TweaksfirewallRule.Description = "Spy domain names";firewallRule.Enabled = true;firewallRule.InterfaceTypes = "All";- firewallRule.Name = $"GTweak - Spy domain names";+ firewallRule.Name = @"GTweak - Spy domain names";if (isChoose){- firewallPolicy.Rules.Remove($"GTweak - Spy domain names");+ firewallPolicy.Rules.Remove(@"GTweak - Spy domain names");firewallPolicy.Rules.Add(firewallRule);}else- firewallPolicy.Rules.Remove($"GTweak - Spy domain names");+ firewallPolicy.Rules.Remove(@"GTweak - Spy domain names");}}}diff --git a/.Source/GTweak/Utilities/Tweaks/SystemTweaks.cs b/.Source/GTweak/Utilities/Tweaks/SystemTweaks.csindex 4ba13151..3475d07b 100644--- a/.Source/GTweak/Utilities/Tweaks/SystemTweaks.cs+++ b/.Source/GTweak/Utilities/Tweaks/SystemTweaks.cs@@ -243,8 +243,8 @@ namespace GTweak.Utilities.TweakselsesystemV.TglButton17.StateNA = false;- if (!Registry.GetValue(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\User\PowerSchemes\" + activeGuid + "", "Description", null).ToString().Contains("-18") &&- !Registry.GetValue(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\User\PowerSchemes\" + activeGuid + "", "FriendlyName", null).ToString().Contains("-19"))+ if (!Registry.GetValue(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\User\PowerSchemes\" + activeGuid + "", "Description", string.Empty).ToString().Contains("-18") &&+ !Registry.GetValue(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\User\PowerSchemes\" + activeGuid + "", "FriendlyName", string.Empty).ToString().Contains("-19"))systemV.TglButton18.StateNA = true;elsesystemV.TglButton18.StateNA = false;@@ -669,7 +669,7 @@ namespace GTweak.Utilities.Tweaks});}- private static void SetPowercfg(bool isChoose)+ private async static void SetPowercfg(bool isChoose){Process _powercfg = new Process(){@@ -679,7 +679,10 @@ namespace GTweak.Utilities.TweaksWindowStyle = ProcessWindowStyle.Hidden},};- string _serchScheme = default;++ string _serchScheme = default,+ unlockFrequency = @"-attributes SUB_PROCESSOR 75b0ae3f-bce0-45a7-8c89-c9611c25e100 -ATTRIB_HIDE",+ inputPath = Settings.PathTempFiles + @"\UltimatePerformance.pow";try{@@ -699,7 +702,7 @@ namespace GTweak.Utilities.Tweaks_powercfg.StartInfo.Arguments = $"/setactive {_serchScheme}";_powercfg.Start();- _powercfg.StartInfo.Arguments = @"-attributes SUB_PROCESSOR 75b0ae3f-bce0-45a7-8c89-c9611c25e100 -ATTRIB_HIDE";+ _powercfg.StartInfo.Arguments = unlockFrequency;_powercfg.Start();}}@@ -726,17 +729,15 @@ namespace GTweak.Utilities.Tweaksusing (_powercfg){- string inputPath = Settings.PathTempFiles + @"\UltimatePerformance.pow";-_powercfg.StartInfo.Arguments = $"-import \"{inputPath}\" {_guid}";_powercfg.Start();- Thread.Sleep(3);+ await Task.Delay(5);_powercfg.StartInfo.Arguments = $"/setactive {_guid}";_powercfg.Start();- _powercfg.StartInfo.Arguments = @"-attributes SUB_PROCESSOR 75b0ae3f-bce0-45a7-8c89-c9611c25e100 -ATTRIB_HIDE";+ _powercfg.StartInfo.Arguments = unlockFrequency;_powercfg.Start();}}