Portable Tool for an Ideal Windows Setup
C# activatorbloatware-removalcsharpdebloatdebloaterdisable-servicesmonitoring-systemportableprivacy-toolsregistry-tweakssystem-tuningsystem-utilitytelemetrytweakerwindows-10windows-11windows-debloatwindows-defenderwindows-optimizationwindows-tweaks
fixed eventWatcher (global msft class verification) & re
Greedeks211440704219
diff --git a/.Source/GTweak/GTweak.csproj b/.Source/GTweak/GTweak.csprojindex 0a9857f1..9d5e2b4a 100644--- a/.Source/GTweak/GTweak.csproj+++ b/.Source/GTweak/GTweak.csproj@@ -276,6 +276,7 @@<Compile Include="Utilities\Helpers\DisablingWinKeys.cs" /><Compile Include="Utilities\Helpers\CommandExecutor.cs" /><Compile Include="Utilities\Managers\ExplorerManager.cs" />+ <Compile Include="Utilities\Managers\FirewallManager.cs" /><Compile Include="Utilities\Managers\OverlayDialogManager.cs" /><Compile Include="Utilities\Managers\TimerControlManager.cs" /><Compile Include="Utilities\Storage\WinKeyStorage.cs" />@@ -293,7 +294,6 @@<Compile Include="Utilities\Helpers\TrustedInstaller.cs" /><Compile Include="Utilities\Tweaks\ConfidentialityTweaks.cs" /><Compile Include="Utilities\Tweaks\DefenderManager\BackupRights.cs" />- <Compile Include="Utilities\Tweaks\Firewall.cs" /><Compile Include="Utilities\Tweaks\InterfaceTweaks.cs" /><Compile Include="Utilities\Tweaks\NTFSCompressor.cs" /><Compile Include="Utilities\Tweaks\ServicesTweaks.cs" />diff --git a/.Source/GTweak/Utilities/Configuration/MonitoringService.cs b/.Source/GTweak/Utilities/Configuration/MonitoringService.csindex ce32af30..7688ed8f 100644--- a/.Source/GTweak/Utilities/Configuration/MonitoringService.cs+++ b/.Source/GTweak/Utilities/Configuration/MonitoringService.cs@@ -5,6 +5,7 @@ using System.Diagnostics;using System.Management;using System.Runtime.InteropServices;using System.ServiceProcess;+using System.Threading;using System.Threading.Tasks;namespace GTweak.Utilities.Configuration@@ -96,18 +97,18 @@ namespace GTweak.Utilities.Configuration{return Task.Run(() =>{- int number = 0;- foreach (ServiceController svc in _servicesList)+ int running = 0;+ Parallel.ForEach(_servicesList, svc =>{try{svc.Refresh();if (svc.Status == ServiceControllerStatus.Running)- ++number;+ Interlocked.Increment(ref running);}catch (Exception ex) { ErrorLogging.LogDebug(ex); }- }- return number.ToString();+ });+ return running.ToString();});}@@ -162,20 +163,21 @@ namespace GTweak.Utilities.Configuration{Task.Run(() =>{- foreach (var wmiClass in new[] { "Win32_DiskDrive", "MSFT_PhysicalDisk" })- SubscribeToDeviceEvents($"TargetInstance ISA '{wmiClass}'", DeviceType.Storage);+ if (SystemDiagnostics.isMsftAvailable)+ SubscribeToDeviceEvents($"TargetInstance ISA 'MSFT_PhysicalDisk'", DeviceType.Storage, @"root\Microsoft\Windows\Storage");+ else+ SubscribeToDeviceEvents($"TargetInstance ISA 'Win32_DiskDrive'", DeviceType.Storage);SubscribeToDeviceEvents("TargetInstance ISA 'Win32_SoundDevice'", DeviceType.Audio);SubscribeToDeviceEvents("TargetInstance ISA 'Win32_NetworkAdapter' AND TargetInstance.NetConnectionStatus IS NOT NULL", DeviceType.Network);}).ConfigureAwait(false);}-- private void SubscribeToDeviceEvents(string filter, DeviceType type)+ private void SubscribeToDeviceEvents(string filter, DeviceType type, string scope = @"root\CIMV2"){try{WqlEventQuery query = new WqlEventQuery("__InstanceOperationEvent", TimeSpan.FromSeconds(1), filter);- ManagementEventWatcher managementEvent = new ManagementEventWatcher(query);+ ManagementEventWatcher managementEvent = new ManagementEventWatcher(new ManagementScope(scope), query);managementEvent.EventArrived += (s, e) => { HandleDevicesEvents?.Invoke(type); };managementEvent.Start();_eventWatchers.Add(managementEvent);diff --git a/.Source/GTweak/Utilities/Configuration/SystemDiagnostics.cs b/.Source/GTweak/Utilities/Configuration/SystemDiagnostics.csindex 9d4303dc..5521317d 100644--- a/.Source/GTweak/Utilities/Configuration/SystemDiagnostics.cs+++ b/.Source/GTweak/Utilities/Configuration/SystemDiagnostics.cs@@ -84,7 +84,7 @@ namespace GTweak.Utilities.Configurationinternal static Dictionary<byte, bool> IsWindowsVersion = default;- internal static bool isIPAddressFormatValid = false;+ internal static bool isIPAddressFormatValid = false, isMsftAvailable = false;internal ImageSource GetProfileImage(){@@ -104,6 +104,14 @@ namespace GTweak.Utilities.Configurationinternal void GetHardwareData(){+ try+ {+ using var managementObj = new ManagementObjectSearcher(@"root\microsoft\windows\storage", "select FriendlyName from MSFT_PhysicalDisk", new EnumerationOptions { ReturnImmediately = true });+ var results = managementObj.Get();+ isMsftAvailable = results != null && results.Count > 0;+ }+ catch { isMsftAvailable = false; }+Parallel.Invoke(GetBiosInfo,GetMotherboardInfo,@@ -339,17 +347,8 @@ namespace GTweak.Utilities.Configurationprivate string GetStorageDevices(){StringBuilder result = new StringBuilder();- bool isMsftWorking = false;-- try- {- using var managementObj = new ManagementObjectSearcher(@"root\microsoft\windows\storage", "select FriendlyName from MSFT_PhysicalDisk", new EnumerationOptions { ReturnImmediately = true });- var results = managementObj.Get();- isMsftWorking = results != null && results.Count > 0;- }- catch { isMsftWorking = false; }- if (isMsftWorking)+ if (isMsftAvailable){foreach (var managementObj in new ManagementObjectSearcher(@"root\microsoft\windows\storage", "select FriendlyName, Model, Description, MediaType, Size, BusType from MSFT_PhysicalDisk", new EnumerationOptions { ReturnImmediately = true }).Get()){diff --git a/.Source/GTweak/Utilities/Tweaks/Firewall.cs b/.Source/GTweak/Utilities/Managers/FirewallManager.cssimilarity index 98%rename from .Source/GTweak/Utilities/Tweaks/Firewall.csrename to .Source/GTweak/Utilities/Managers/FirewallManager.csindex 87562a2a..c11f073b 100644--- a/.Source/GTweak/Utilities/Tweaks/Firewall.cs+++ b/.Source/GTweak/Utilities/Managers/FirewallManager.cs@@ -1,14 +1,13 @@using GTweak.Utilities.Controls;-using GTweak.Utilities.Managers;using NetFwTypeLib;using System;using System.Collections.Generic;using System.IO;using System.Threading.Tasks;-namespace GTweak.Utilities.Tweaks+namespace GTweak.Utilities.Managers{- internal class Firewall : TaskSchedulerManager+ internal class FirewallManager : TaskSchedulerManager{private static readonly SortedList<string, string> _nameRules = new SortedList<string, string>{diff --git a/.Source/GTweak/Utilities/Storage/TaskStorage.cs b/.Source/GTweak/Utilities/Storage/TaskStorage.csindex 029b8360..9862d868 100644--- a/.Source/GTweak/Utilities/Storage/TaskStorage.cs+++ b/.Source/GTweak/Utilities/Storage/TaskStorage.cs@@ -83,17 +83,17 @@ namespace GTweak.Utilities.Storage@"\Microsoft\Windows\MemoryDiagnostic\RunFullMemoryDiagnostic" };protected static readonly string[] winInsiderTasks = {- @"Microsoft\Windows\Flighting\FeatureConfig\BootstrapUsageDataReporting",- @"Microsoft\Windows\Flighting\FeatureConfig\GovernedFeatureUsageProcessing",- @"Microsoft\Windows\Flighting\FeatureConfig\ReconcileConfigs",- @"Microsoft\Windows\Flighting\FeatureConfig\ReconcileFeatures",- @"Microsoft\Windows\Flighting\FeatureConfig\UsageDataFlushing",- @"Microsoft\Windows\Flighting\FeatureConfig\UsageDataReceiver",- @"Microsoft\Windows\Flighting\FeatureConfig\UsageDataReporting",- @"Microsoft\Windows\Flighting\OneSettings\RefreshCache",- @"Microsoft\Windows\Flighting\OneSettings\CollectUsageData",- @"Microsoft\Windows\Flighting\OneSettings\SyncConfigs",- @"Microsoft\Windows\Flighting\OneSettings\TrackFlighting" };+ @"\Microsoft\Windows\Flighting\FeatureConfig\BootstrapUsageDataReporting",+ @"\Microsoft\Windows\Flighting\FeatureConfig\GovernedFeatureUsageProcessing",+ @"\Microsoft\Windows\Flighting\FeatureConfig\ReconcileConfigs",+ @"\Microsoft\Windows\Flighting\FeatureConfig\ReconcileFeatures",+ @"\Microsoft\Windows\Flighting\FeatureConfig\UsageDataFlushing",+ @"\Microsoft\Windows\Flighting\FeatureConfig\UsageDataReceiver",+ @"\Microsoft\Windows\Flighting\FeatureConfig\UsageDataReporting",+ @"\Microsoft\Windows\Flighting\OneSettings\RefreshCache",+ @"\Microsoft\Windows\Flighting\OneSettings\CollectUsageData",+ @"\Microsoft\Windows\Flighting\OneSettings\SyncConfigs",+ @"\Microsoft\Windows\Flighting\OneSettings\TrackFlighting" };protected static readonly string restoreTask = @"\Microsoft\Windows\SystemRestore\SR";diff --git a/.Source/GTweak/Utilities/Tweaks/ConfidentialityTweaks.cs b/.Source/GTweak/Utilities/Tweaks/ConfidentialityTweaks.csindex bff49ed9..20fa2847 100644--- a/.Source/GTweak/Utilities/Tweaks/ConfidentialityTweaks.cs+++ b/.Source/GTweak/Utilities/Tweaks/ConfidentialityTweaks.cs@@ -12,7 +12,7 @@ using System.Threading.Tasks;namespace GTweak.Utilities.Tweaks{- internal sealed class ConfidentialityTweaks : Firewall+ internal sealed class ConfidentialityTweaks : FirewallManager{internal void AnalyzeAndUpdate(ConfidentialityView confidentialityV){diff --git a/.Source/GTweak/Utilities/Tweaks/ServicesTweaks.cs b/.Source/GTweak/Utilities/Tweaks/ServicesTweaks.csindex 77e4924c..c5d1c23f 100644--- a/.Source/GTweak/Utilities/Tweaks/ServicesTweaks.cs+++ b/.Source/GTweak/Utilities/Tweaks/ServicesTweaks.cs@@ -14,7 +14,7 @@ using System.Threading.Tasks;namespace GTweak.Utilities.Tweaks{- internal sealed class ServicesTweaks : Firewall+ internal sealed class ServicesTweaks : FirewallManager{private static readonly Dictionary<string, (string Default, string Blocked)> _updateFilesWin = new Dictionary<string, (string Default, string Blocked)>(){diff --git a/.Source/GTweak/Utilities/Tweaks/SystemTweaks.cs b/.Source/GTweak/Utilities/Tweaks/SystemTweaks.csindex 6485d602..1602fbcc 100644--- a/.Source/GTweak/Utilities/Tweaks/SystemTweaks.cs+++ b/.Source/GTweak/Utilities/Tweaks/SystemTweaks.cs@@ -26,7 +26,7 @@ namespace GTweak.Utilities.Tweaksinternal const uint SPI_SETMOUSE = 0x0004;};- internal sealed class SystemTweaks : Firewall+ internal sealed class SystemTweaks : FirewallManager{private static bool _isNetshState = false, _isBluetoothStatus = false, _isTickState = false;private readonly string _activeGuid = RegistryHelp.GetValue(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\User\PowerSchemes", "ActivePowerScheme", string.Empty);