Portable Tool for an Ideal Windows Setup
C# activatorbloatware-removalcsharpdebloatdebloaterdisable-servicesmonitoring-systemportableprivacy-toolsregistry-tweakssystem-tuningsystem-utilitytelemetrytweakerwindows-10windows-11windows-debloatwindows-defenderwindows-optimizationwindows-tweaks
v 4.90.9 -fixed sound noty & ref
Greedeksbec760a852cc
diff --git a/.Source/GTweak/Properties/AssemblyInfo.cs b/.Source/GTweak/Properties/AssemblyInfo.csindex a0384519..c5a3b760 100644--- a/.Source/GTweak/Properties/AssemblyInfo.cs+++ b/.Source/GTweak/Properties/AssemblyInfo.cs@@ -10,8 +10,8 @@ using System.Windows;[assembly: AssemblyCopyright("Copyright © Greedeks 2024")][assembly: AssemblyTrademark("Greedeks")][assembly: AssemblyCulture("")]-[assembly: AssemblyInformationalVersion("Build: 4.90.8")]-[assembly: AssemblyFileVersion("4.90.8")]+[assembly: AssemblyInformationalVersion("Build: 4.90.9")]+[assembly: AssemblyFileVersion("4.90.9")][assembly: ComVisible(false)]diff --git a/.Source/GTweak/Utilities/Helpers/BrushAnimation.cs b/.Source/GTweak/Utilities/Helpers/BrushAnimation.csindex 739c27ba..877a55a9 100644--- a/.Source/GTweak/Utilities/Helpers/BrushAnimation.cs+++ b/.Source/GTweak/Utilities/Helpers/BrushAnimation.cs@@ -8,10 +8,8 @@ namespace GTweak.Utilities.Helpers{internal sealed class BrushAnimation : AnimationTimeline{- protected override Freezable CreateInstanceCore()- {- return new BrushAnimation();- }+ protected override Freezable CreateInstanceCore() => new BrushAnimation();+public override Type TargetPropertyType => typeof(Brush);@@ -55,20 +53,20 @@ namespace GTweak.Utilities.HelperstoVal.Opacity = Convert.ToDouble(animationClock.CurrentProgress);- Border border0 = new Border();- Border border1 = new Border();+ Border borderFrom = new Border();+ Border borderTo = new Border();- border0.Width = 1.0;- border0.Height = 1.0;+ borderFrom.Width = 1.0;+ borderFrom.Height = 1.0;- border0.Background = fromVal;- border1.Background = toVal;+ borderFrom.Background = fromVal;+ borderTo.Background = toVal;- border0.Visibility = Visibility.Visible;- border1.Visibility = Visibility.Visible;- border0.Child = border1;+ borderFrom.Visibility = Visibility.Visible;+ borderTo.Visibility = Visibility.Visible;+ borderFrom.Child = borderTo;- Brush vb = new VisualBrush(border0);+ Brush vb = new VisualBrush(borderFrom);return vb;}diff --git a/.Source/GTweak/Utilities/Helpers/INIManager.cs b/.Source/GTweak/Utilities/Helpers/INIManager.csindex 35e75e40..2e0831f6 100644--- a/.Source/GTweak/Utilities/Helpers/INIManager.cs+++ b/.Source/GTweak/Utilities/Helpers/INIManager.cs@@ -8,9 +8,9 @@ namespace GTweak.Utilities.Helpers{internal sealed class INIManager{- [DllImport("kernel32")]+ [DllImport("kernel32.dll")]private static extern long WritePrivateProfileString(string section, string key, string value, string filePath);- [DllImport("kernel32")]+ [DllImport("kernel32.dll")]private static extern int GetPrivateProfileString(string section, string key, string _default, StringBuilder retVal, int size, string filePath);[DllImport("kernel32.dll")]private static extern int GetPrivateProfileSection(string section, StringBuilder retVal, int size, string filePath);diff --git a/.Source/GTweak/Utilities/Helpers/RegistryHelp.cs b/.Source/GTweak/Utilities/Helpers/RegistryHelp.csindex 6c3e44c8..9514bc94 100644--- a/.Source/GTweak/Utilities/Helpers/RegistryHelp.cs+++ b/.Source/GTweak/Utilities/Helpers/RegistryHelp.cs@@ -23,7 +23,6 @@ namespace GTweak.Utilities.Helperstry { registrykey.CreateSubKey(key, true)?.SetValue(name, data, kind); } catch (Exception ex) { Debug.WriteLine(ex.Message.ToString()); }}-internal static void CreateFolder(in RegistryKey registrykey, in string subkey){try { registrykey.CreateSubKey(subkey); } catch (Exception ex) { Debug.WriteLine(ex.Message.ToString()); }@@ -39,11 +38,7 @@ namespace GTweak.Utilities.Helpers{foreach (string value in registryFolder.GetValueNames()){- try- {- registryFolder.DeleteValue(value);- }- catch (Exception ex) { Debug.WriteLine(ex.Message.ToString()); }+ try { registryFolder.DeleteValue(value); } catch (Exception ex) { Debug.WriteLine(ex.Message.ToString()); }}}diff --git a/.Source/GTweak/Utilities/Tweaks/ClearingMemory.cs b/.Source/GTweak/Utilities/Tweaks/ClearingMemory.csindex dfe328e6..993db88f 100644--- a/.Source/GTweak/Utilities/Tweaks/ClearingMemory.cs+++ b/.Source/GTweak/Utilities/Tweaks/ClearingMemory.cs@@ -229,8 +229,8 @@ namespace GTweak.Utilities.Tweaks};backgroundWorker.RunWorkerCompleted += delegate{- new Thread(() => backgroundWorker.Dispose()).Start();- new Thread(() => backgroundWorker.Dispose()).IsBackground = true;+ Thread _thread = new Thread(() => backgroundWorker.Dispose()) { IsBackground = true };+ _thread.Start();new ViewNotification().Show("", (string)Application.Current.Resources["title1_notification"], (string)Application.Current.Resources["clear_ram_notification"]);};backgroundWorker.RunWorkerAsync();diff --git a/.Source/GTweak/Utilities/Tweaks/ConfidentialityTweaks.cs b/.Source/GTweak/Utilities/Tweaks/ConfidentialityTweaks.csindex 84b8c17a..d29aa2f1 100644--- a/.Source/GTweak/Utilities/Tweaks/ConfidentialityTweaks.cs+++ b/.Source/GTweak/Utilities/Tweaks/ConfidentialityTweaks.cs@@ -47,6 +47,8 @@ namespace GTweak.Utilities.Tweaks@"0.0.0.0 watson.live.com",@"0.0.0.0 api.cortana.ai" };+ private static Thread _thread = default;+internal void ViewСonfidentiality(ConfidentialityView confidentialityV){if (Registry.GetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\AdvertisingInfo", "Enabled", null) == null ||@@ -307,16 +309,14 @@ namespace GTweak.Utilities.Tweaks}break;case "TglButton4":- if (isChoose)- {- new Thread(() => DisablingTasks(SchedulerTasks)).Start();- new Thread(() => DisablingTasks(SchedulerTasks)).IsBackground = true;- }- else+ _thread = new Thread(() =>{- new Thread(() => EnablingTasks(SchedulerTasks)).Start();- new Thread(() => EnablingTasks(SchedulerTasks)).IsBackground = true;- }+ if (isChoose)+ DisablingTasks(SchedulerTasks);+ else+ EnablingTasks(SchedulerTasks);+ }) { IsBackground = true };+ _thread.Start();break;case "TglButton5":if (isChoose)@@ -454,16 +454,14 @@ namespace GTweak.Utilities.Tweaks}break;case "TglButton16":- if (isChoose)+ static void LoggingServices(string valueState){- TrustedInstaller.CreateProcessAsTrustedInstaller(Settings.PID, "cmd.exe /c reg add HKLM\\SYSTEM\\CurrentControlSet\\Services\\diagnosticshub.standardcollector.service /t REG_DWORD /v Start /d 4 /f");- RegistryHelp.Write(Registry.LocalMachine, @"SYSTEM\CurrentControlSet\Services\diagnosticshub.standardcollector.service", "Start", 4, RegistryValueKind.DWord);- }- else- {- TrustedInstaller.CreateProcessAsTrustedInstaller(Settings.PID, "cmd.exe /c reg add HKLM\\SYSTEM\\CurrentControlSet\\Services\\diagnosticshub.standardcollector.service /t REG_DWORD /v Start /d 3 /f");- RegistryHelp.Write(Registry.LocalMachine, @"SYSTEM\CurrentControlSet\Services\diagnosticshub.standardcollector.service", "Start", 3, RegistryValueKind.DWord);+ TrustedInstaller.CreateProcessAsTrustedInstaller(Settings.PID, $"cmd.exe /c reg add HKLM\\SYSTEM\\CurrentControlSet\\Services\\diagnosticshub.standardcollector.service /t REG_DWORD /v Start /d {valueState} /f");+ RegistryHelp.Write(Registry.LocalMachine, @"SYSTEM\CurrentControlSet\Services\diagnosticshub.standardcollector.service", "Start", int.Parse(valueState), RegistryValueKind.DWord);}++ _thread = new Thread(() => LoggingServices(isChoose ? "4" : "3")) { IsBackground = true };+ _thread.Start();break;case "TglButton17":if (isChoose)diff --git a/.Source/GTweak/Utilities/Tweaks/InterfaceTweaks.cs b/.Source/GTweak/Utilities/Tweaks/InterfaceTweaks.csindex 39416467..b03716cf 100644--- a/.Source/GTweak/Utilities/Tweaks/InterfaceTweaks.cs+++ b/.Source/GTweak/Utilities/Tweaks/InterfaceTweaks.cs@@ -333,29 +333,33 @@ namespace GTweak.Utilities.Tweaksprivate static void RestartExplorer(Process launchExplorer){- foreach (Process process in Process.GetProcesses())+ Thread _thread = new Thread(() =>{- try+ foreach (Process process in Process.GetProcesses()){- if (string.Compare(process.MainModule?.FileName, $"{Environment.GetEnvironmentVariable("WINDIR")}\\{"explorer.exe"}", StringComparison.OrdinalIgnoreCase) == 0)+ try{- process.Kill();- process.Start();+ if (string.Compare(process.MainModule?.FileName, $"{Environment.GetEnvironmentVariable("WINDIR")}\\{"explorer.exe"}", StringComparison.OrdinalIgnoreCase) == 0)+ {+ process.Kill();+ process.Start();+ }}- }- catch (Exception ex) { Debug.WriteLine(ex.Message.ToString()); }- finally- {- Process[] explorer = Process.GetProcessesByName("explorer");- if (explorer.Length == 0)+ catch (Exception ex) { Debug.WriteLine(ex.Message.ToString()); }+ finally{- launchExplorer.StartInfo.FileName = $"{Environment.GetEnvironmentVariable("WINDIR")}\\{"explorer.exe"}";- launchExplorer.StartInfo.UseShellExecute = true;- launchExplorer.Start();- }+ Process[] explorer = Process.GetProcessesByName("explorer");+ if (explorer.Length == 0)+ {+ launchExplorer.StartInfo.FileName = $"{Environment.GetEnvironmentVariable("WINDIR")}\\{"explorer.exe"}";+ launchExplorer.StartInfo.UseShellExecute = true;+ launchExplorer.Start();+ }+ }}- }+ }) { IsBackground = true };+ _thread.Start();}internal static void UseInterface(string tweak, bool isChoose)@@ -432,16 +436,16 @@ namespace GTweak.Utilities.TweaksRegistryHelp.Write(Registry.CurrentUser, @"Software\Microsoft\Windows\CurrentVersion\Themes\Personalize", "SystemUsesLightTheme", 1, RegistryValueKind.DWord);elseRegistryHelp.Write(Registry.CurrentUser, @"Software\Microsoft\Windows\CurrentVersion\Themes\Personalize", "SystemUsesLightTheme", 0, RegistryValueKind.DWord);- new Thread(() => RestartExplorer(new Process())).Start();- new Thread(() => RestartExplorer(new Process())).IsBackground = true;++ RestartExplorer(new Process());break;case "TglButton8":if (isChoose)RegistryHelp.Write(Registry.CurrentUser, @"Software\Microsoft\Windows\CurrentVersion\Themes\Personalize", "AppsUseLightTheme", 1, RegistryValueKind.DWord);elseRegistryHelp.Write(Registry.CurrentUser, @"Software\Microsoft\Windows\CurrentVersion\Themes\Personalize", "AppsUseLightTheme", 0, RegistryValueKind.DWord);- new Thread(() => RestartExplorer(new Process())).Start();- new Thread(() => RestartExplorer(new Process())).IsBackground = true;++ RestartExplorer(new Process());break;case "TglButton9":if (isChoose)@@ -518,8 +522,7 @@ namespace GTweak.Utilities.TweakselseRegistryHelp.DeleteFolderTree(Registry.CurrentUser, @"Software\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}");- new Thread(() => RestartExplorer(new Process())).Start();- new Thread(() => RestartExplorer(new Process())).IsBackground = true;+ RestartExplorer(new Process());break;case "TglButton18":if (isChoose)@@ -553,8 +556,7 @@ namespace GTweak.Utilities.TweaksRegistryHelp.Write(Registry.LocalMachine, @"SOFTWARE\Microsoft\PolicyManager\default\NewsAndInterests\AllowNewsAndInterests", "value", "0", RegistryValueKind.DWord);RegistryHelp.Write(Registry.CurrentUser, @"Software\Microsoft\Windows\CurrentVersion\Feeds", "ShellFeedsTaskbarViewMode", 2, RegistryValueKind.DWord);RegistryHelp.Write(Registry.CurrentUser, @"Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "ShowCortanaButton", 0, RegistryValueKind.DWord);- new Thread(() => RestartExplorer(new Process())).Start();- new Thread(() => RestartExplorer(new Process())).IsBackground = true;+ RestartExplorer(new Process());}}else@@ -576,8 +578,7 @@ namespace GTweak.Utilities.TweaksRegistryHelp.DeleteFolderTree(Registry.LocalMachine, @"SOFTWARE\Microsoft\PolicyManager\default\NewsAndInterests\AllowNewsAndInterests");RegistryHelp.Write(Registry.CurrentUser, @"Software\Microsoft\Windows\CurrentVersion\Feeds", "ShellFeedsTaskbarViewMode", 0, RegistryValueKind.DWord);RegistryHelp.Write(Registry.CurrentUser, @"Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "ShowCortanaButton", 1, RegistryValueKind.DWord);- new Thread(() => RestartExplorer(new Process())).Start();- new Thread(() => RestartExplorer(new Process())).IsBackground = true;+ RestartExplorer(new Process());}}break;diff --git a/.Source/GTweak/Utilities/Tweaks/ServicesTweaks.cs b/.Source/GTweak/Utilities/Tweaks/ServicesTweaks.csindex 3d68b473..afb9cfee 100644--- a/.Source/GTweak/Utilities/Tweaks/ServicesTweaks.cs+++ b/.Source/GTweak/Utilities/Tweaks/ServicesTweaks.cs@@ -8,6 +8,7 @@ using System.Diagnostics;using System.IO;using System.Security.AccessControl;using System.Security.Principal;+using System.Threading;namespace GTweak.Utilities.Tweaks{@@ -427,10 +428,8 @@ namespace GTweak.Utilities.Tweaks}break;case "TglButton4":- static void StoreServices(bool isChoose)+ static void StoreServices (string value){- string value = isChoose ? "4" : "3";-TrustedInstaller.CreateProcessAsTrustedInstaller(Settings.PID, $"cmd.exe /c reg add HKLM\\SYSTEM\\CurrentControlSet\\Services\\WalletService /t REG_DWORD /v Start /d {value} /f & " +$"reg add HKLM\\SYSTEM\\CurrentControlSet\\Services\\VacSvc /t REG_DWORD /v Start /d {value} /f & " +$"reg add HKLM\\SYSTEM\\CurrentControlSet\\Services\\spectrum /t REG_DWORD /v Start /d {value} /f & " +@@ -447,11 +446,8 @@ namespace GTweak.Utilities.Tweaks$"reg add HKLM\\SYSTEM\\CurrentControlSet\\Services\\InstallService /t REG_DWORD /v Start /d {value} /f");}- using (BackgroundWorker backgroundWorker = new BackgroundWorker())- {- backgroundWorker.DoWork += delegate { StoreServices(isChoose); };- backgroundWorker.RunWorkerAsync();- }+ Thread _thread = new Thread(() => StoreServices(isChoose ? "4" : "3")) { IsBackground = true };+ _thread.Start();break;case "TglButton5":if (isChoose)@@ -641,11 +637,7 @@ namespace GTweak.Utilities.TweaksRegistryHelp.Write(Registry.LocalMachine, @"SYSTEM\CurrentControlSet\Services\UsoSvc", "Start", 2, RegistryValueKind.DWord);RegistryHelp.DeleteFolderTree(Registry.LocalMachine, @"SOFTWARE\Microsoft\Windows\WindowsUpdate");}- using (BackgroundWorker backgroundWorker = new BackgroundWorker())- {- backgroundWorker.DoWork += delegate { ChangeAccessUpdateFolders(isChoose); };- backgroundWorker.RunWorkerAsync();- }+ ChangeAccessUpdateFolders(isChoose);break;case "TglButton16":if (isChoose)@@ -847,51 +839,56 @@ namespace GTweak.Utilities.Tweaksprivate static void ChangeAccessUpdateFolders(bool isDenyAccess){- void SetFullAccess(string path)- {- FileSecurity security = File.GetAccessControl(path);- security.SetOwner(WindowsIdentity.GetCurrent().User);- security.SetAccessRule(new FileSystemAccessRule(WindowsIdentity.GetCurrent().User, FileSystemRights.FullControl, AccessControlType.Allow));- File.SetAccessControl(path, security);- }-- void ChangeStateTask(string valueState = "/disable")+ Thread _thread = new Thread(() =>{- TrustedInstaller.CreateProcessAsTrustedInstaller(Settings.PID, "cmd.exe /c schtasks /change " + valueState + " /tn \"\\Microsoft\\Windows\\UpdateOrchestrator\\Report policies\" & " +- "schtasks /change " + valueState + " /tn \"\\Microsoft\\Windows\\UpdateOrchestrator\\Schedule Scan\" & " +- "schtasks /change " + valueState + " /tn \"\\Microsoft\\Windows\\UpdateOrchestrator\\Schedule Scan Static Task\" & " +- "schtasks /change " + valueState + " /tn \"\\Microsoft\\Windows\\UpdateOrchestrator\\Schedule Work\" & " +- "schtasks /change " + valueState + " /tn \"\\Microsoft\\Windows\\UpdateOrchestrator\\Start Oobe Expedite Work\" & " +- "schtasks /change " + valueState + " /tn \"\\Microsoft\\Windows\\UpdateOrchestrator\\StartOobeAppsScanAfterUpdate\" & " +- "schtasks /change " + valueState + " /tn \"\\Microsoft\\Windows\\UpdateOrchestrator\\StartOobeAppsScan_LicenseAccepted\" & " +- "schtasks /change " + valueState + " /tn \"\\Microsoft\\Windows\\UpdateOrchestrator\\USO_UxBroker\" & " +- "schtasks /change " + valueState + " /tn \"\\Microsoft\\Windows\\UpdateOrchestrator\\UUS Failover Task\" & " +- "schtasks /change " + valueState + " /tn \"\\Microsoft\\Windows\\WindowsUpdate\\Refresh Group Policy Cache\" & " +- "schtasks /change " + valueState + " /tn \"\\Microsoft\\Windows\\WindowsUpdate\\Scheduled Start\"");- }+ void SetFullAccess(string path)+ {+ FileSecurity security = File.GetAccessControl(path);+ security.SetOwner(WindowsIdentity.GetCurrent().User);+ security.SetAccessRule(new FileSystemAccessRule(WindowsIdentity.GetCurrent().User, FileSystemRights.FullControl, AccessControlType.Allow));+ File.SetAccessControl(path, security);+ }- try- {- if (!isDenyAccess)- ChangeStateTask("/enable");- else+ void ChangeStateTask(string valueState = "/disable"){- SetFullAccess(Settings.PathSystemDisk + @"Windows\SoftwareDistribution\Download");- SetFullAccess(Settings.PathSystemDisk + @"Windows\System32\catroot2");+ TrustedInstaller.CreateProcessAsTrustedInstaller(Settings.PID, "cmd.exe /c schtasks /change " + valueState + " /tn \"\\Microsoft\\Windows\\UpdateOrchestrator\\Report policies\" & " ++ "schtasks /change " + valueState + " /tn \"\\Microsoft\\Windows\\UpdateOrchestrator\\Schedule Scan\" & " ++ "schtasks /change " + valueState + " /tn \"\\Microsoft\\Windows\\UpdateOrchestrator\\Schedule Scan Static Task\" & " ++ "schtasks /change " + valueState + " /tn \"\\Microsoft\\Windows\\UpdateOrchestrator\\Schedule Work\" & " ++ "schtasks /change " + valueState + " /tn \"\\Microsoft\\Windows\\UpdateOrchestrator\\Start Oobe Expedite Work\" & " ++ "schtasks /change " + valueState + " /tn \"\\Microsoft\\Windows\\UpdateOrchestrator\\StartOobeAppsScanAfterUpdate\" & " ++ "schtasks /change " + valueState + " /tn \"\\Microsoft\\Windows\\UpdateOrchestrator\\StartOobeAppsScan_LicenseAccepted\" & " ++ "schtasks /change " + valueState + " /tn \"\\Microsoft\\Windows\\UpdateOrchestrator\\USO_UxBroker\" & " ++ "schtasks /change " + valueState + " /tn \"\\Microsoft\\Windows\\UpdateOrchestrator\\UUS Failover Task\" & " ++ "schtasks /change " + valueState + " /tn \"\\Microsoft\\Windows\\WindowsUpdate\\Refresh Group Policy Cache\" & " ++ "schtasks /change " + valueState + " /tn \"\\Microsoft\\Windows\\WindowsUpdate\\Scheduled Start\"");+ }- Process.Start(new ProcessStartInfo()+ try+ {+ if (!isDenyAccess)+ ChangeStateTask("/enable");+ else{- Arguments = @" /c rd /s /q " + Settings.PathSystemDisk + @"Windows\SoftwareDistribution\Download &+ SetFullAccess(Settings.PathSystemDisk + @"Windows\SoftwareDistribution\Download");+ SetFullAccess(Settings.PathSystemDisk + @"Windows\System32\catroot2");++ Process.Start(new ProcessStartInfo()+ {+ Arguments = @" /c rd /s /q " + Settings.PathSystemDisk + @"Windows\SoftwareDistribution\Download &rd /s /q " + Settings.PathSystemDisk + @"Windows\System32\catroot2",- WindowStyle = ProcessWindowStyle.Hidden,- CreateNoWindow = true,- FileName = "cmd.exe"- });+ WindowStyle = ProcessWindowStyle.Hidden,+ CreateNoWindow = true,+ FileName = "cmd.exe"+ });- ChangeStateTask();+ ChangeStateTask();+ }}- }- catch (Exception ex) { Debug.WriteLine(ex); }+ catch (Exception ex) { Debug.WriteLine(ex); }+ })+ { IsBackground = true };+ _thread.Start();}}}diff --git a/.Source/GTweak/Utilities/Tweaks/SystemTweaks.cs b/.Source/GTweak/Utilities/Tweaks/SystemTweaks.csindex 1fb4d123..080481a1 100644--- a/.Source/GTweak/Utilities/Tweaks/SystemTweaks.cs+++ b/.Source/GTweak/Utilities/Tweaks/SystemTweaks.cs@@ -496,19 +496,21 @@ namespace GTweak.Utilities.Tweaks}break;case "TglButton12":- if (isChoose)+ Thread _thread = new Thread(() =>{- counTaskWorking = 0;- new Thread(() => DisablingTasks()).Start();- new Thread(() => DisablingTasks()).IsBackground = true;-- }- else- {- counTaskWorking = 2;- new Thread(() => EnablingTasks()).Start();- new Thread(() => EnablingTasks()).IsBackground = true;- }+ if (isChoose)+ {+ counTaskWorking = 0;+ DisablingTasks();+ }+ else+ {+ counTaskWorking = 2;+ EnablingTasks();+ }+ })+ { IsBackground = true };+ _thread.Start();break;case "TglButton13":string argumentsNetsh = string.Empty;@@ -572,22 +574,17 @@ namespace GTweak.Utilities.TweaksRegistryHelp.Write(Registry.CurrentUser, @"Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers", "DisableAutoplay", 0, RegistryValueKind.DWord);break;case "TglButton18":- {- new Thread(() => SetPowercfg(isChoose)).Start();- new Thread(() => SetPowercfg(isChoose)).IsBackground = true;- }+ SetPowercfg(isChoose);break;case "TglButton19":if (isChoose){- new Thread(() => BluetoothStatusSet()).Start();- new Thread(() => BluetoothStatusSet()).IsBackground = true;+ BluetoothStatusSet();isBluetoothStatus = false;}else{- new Thread(() => BluetoothStatusSet("'on'")).Start();- new Thread(() => BluetoothStatusSet("'on'")).IsBackground = true;+ BluetoothStatusSet("'on'");isBluetoothStatus = true;}break;@@ -635,12 +632,14 @@ namespace GTweak.Utilities.Tweaks}}- private static void BluetoothStatusSet(in string status = "'off'")+ private static void BluetoothStatusSet(string status = "'off'"){- ProcessStartInfo startInfo = new ProcessStartInfo+ Thread _thread = new Thread(() =>{- FileName = @"powershell.exe",- Arguments = @"Add-Type -AssemblyName System.Runtime.WindowsRuntime+ ProcessStartInfo startInfo = new ProcessStartInfo+ {+ FileName = @"powershell.exe",+ Arguments = @"Add-Type -AssemblyName System.Runtime.WindowsRuntime$asTaskGeneric = ([System.WindowsRuntimeSystemExtensions].GetMethods() | ? { $_.Name -eq 'AsTask' -and $_.GetParameters().Count -eq 1 -and $_.GetParameters()[0].ParameterType.Name -eq 'IAsyncOperation`1' })[0]Function Await($WinRtTask, $ResultType) {$asTask = $asTaskGeneric.MakeGenericMethod($ResultType)@@ -655,12 +654,15 @@ namespace GTweak.Utilities.Tweaks$bluetooth = $radios | ? { $_.Kind -eq 'Bluetooth' }[Windows.Devices.Radios.RadioState,Windows.System.Devices,ContentType=WindowsRuntime] | Out-NullAwait ($bluetooth.SetStateAsync(" + status + ")) ([Windows.Devices.Radios.RadioAccessStatus]) | Out-Null",- UseShellExecute = false,- CreateNoWindow = true- };- using Process process = new Process() { StartInfo = startInfo };- process.Start();- process.Close();+ UseShellExecute = false,+ CreateNoWindow = true+ };+ using Process process = new Process() { StartInfo = startInfo };+ process.Start();+ process.Close();+ })+ { IsBackground = true };+ _thread.Start();}private static void EnablingTasks()@@ -678,7 +680,6 @@ namespace GTweak.Utilities.Tweaks_task.Definition.Settings.Enabled = true;_task.RegisterChanges();}-}}});@@ -704,100 +705,104 @@ namespace GTweak.Utilities.Tweaks});}- private async static void SetPowercfg(bool isChoose)+ private static void SetPowercfg(bool isChoose){- Process _powercfg = new Process()+ Thread _thread = new Thread(async () =>{- StartInfo = {+ Process _powercfg = new Process()+ {+ StartInfo = {FileName = "powercfg",CreateNoWindow = true,WindowStyle = ProcessWindowStyle.Hidden},- };+ };- string _serchScheme = default,- unlockFrequency = @"-attributes SUB_PROCESSOR 75b0ae3f-bce0-45a7-8c89-c9611c25e100 -ATTRIB_HIDE",- inputPath = Settings.PathTempFiles + @"\UltimatePerformance.pow";+ string _serchScheme = default,+ unlockFrequency = @"-attributes SUB_PROCESSOR 75b0ae3f-bce0-45a7-8c89-c9611c25e100 -ATTRIB_HIDE",+ inputPath = Settings.PathTempFiles + @"\UltimatePerformance.pow";- try- {- if (isChoose)+ try{- Parallel.Invoke(() =>+ if (isChoose){- foreach (var managementObj in new ManagementObjectSearcher(@"root\cimv2\power", "SELECT InstanceID FROM Win32_PowerPlan WHERE IsActive=false").Get())+ Parallel.Invoke(() =>{- _serchScheme = Convert.ToString(managementObj["InstanceID"]);- _serchScheme = Regex.Match(_serchScheme, @"\{([^)]*)\}").Groups[1].Value;- if (Registry.GetValue(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\User\PowerSchemes\" + _serchScheme + "", "Description", string.Empty).ToString().Contains("-18") &&- Registry.GetValue(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\User\PowerSchemes\" + _serchScheme + "", "FriendlyName", string.Empty).ToString().Contains("-19"))+ foreach (var managementObj in new ManagementObjectSearcher(@"root\cimv2\power", "SELECT InstanceID FROM Win32_PowerPlan WHERE IsActive=false").Get()){- using (_powercfg)+ _serchScheme = Convert.ToString(managementObj["InstanceID"]);+ _serchScheme = Regex.Match(_serchScheme, @"\{([^)]*)\}").Groups[1].Value;+ if (Registry.GetValue(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\User\PowerSchemes\" + _serchScheme + "", "Description", string.Empty).ToString().Contains("-18") &&+ Registry.GetValue(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\User\PowerSchemes\" + _serchScheme + "", "FriendlyName", string.Empty).ToString().Contains("-19")){- _powercfg.StartInfo.Arguments = $"/setactive {_serchScheme}";- _powercfg.Start();-- _powercfg.StartInfo.Arguments = unlockFrequency;- _powercfg.Start();+ using (_powercfg)+ {+ _powercfg.StartInfo.Arguments = $"/setactive {_serchScheme}";+ _powercfg.Start();++ _powercfg.StartInfo.Arguments = unlockFrequency;+ _powercfg.Start();+ }}}- }- });+ });- if (string.IsNullOrEmpty(_serchScheme))- {- byte[] _byte = default;- using (MemoryStream fileOut = new MemoryStream(Properties.Resources.Ultimate_Performance_pow))- using (GZipStream gz = new GZipStream(fileOut, CompressionMode.Decompress))- using (MemoryStream ms = new MemoryStream())+ if (string.IsNullOrEmpty(_serchScheme)){- gz.CopyTo(ms);- _byte = ms.ToArray();- }+ byte[] _byte = default;+ using (MemoryStream fileOut = new MemoryStream(Properties.Resources.Ultimate_Performance_pow))+ using (GZipStream gz = new GZipStream(fileOut, CompressionMode.Decompress))+ using (MemoryStream ms = new MemoryStream())+ {+ gz.CopyTo(ms);+ _byte = ms.ToArray();+ }- Directory.CreateDirectory(Settings.PathTempFiles);- File.WriteAllBytes(Settings.PathTempFiles + @"\UltimatePerformance.pow", _byte);+ Directory.CreateDirectory(Settings.PathTempFiles);+ File.WriteAllBytes(Settings.PathTempFiles + @"\UltimatePerformance.pow", _byte);- string _guid = Guid.NewGuid().ToString("D");+ string _guid = Guid.NewGuid().ToString("D");- using (_powercfg)- {- _powercfg.StartInfo.Arguments = $"-import \"{inputPath}\" {_guid}";- _powercfg.Start();+ using (_powercfg)+ {+ _powercfg.StartInfo.Arguments = $"-import \"{inputPath}\" {_guid}";+ _powercfg.Start();- await Task.Delay(5);+ await Task.Delay(5);- _powercfg.StartInfo.Arguments = $"/setactive {_guid}";- _powercfg.Start();+ _powercfg.StartInfo.Arguments = $"/setactive {_guid}";+ _powercfg.Start();- _powercfg.StartInfo.Arguments = unlockFrequency;- _powercfg.Start();+ _powercfg.StartInfo.Arguments = unlockFrequency;+ _powercfg.Start();+ }}}- }- else- {- string _activePowerScheme = @"Microsoft:PowerPlan\\{" + Registry.LocalMachine.OpenSubKey(@"SYSTEM\CurrentControlSet\Control\Power\User\PowerSchemes").GetValue("ActivePowerScheme").ToString() + "}";-- Parallel.Invoke(() =>+ else{- foreach (var managementObj in new ManagementObjectSearcher(@"root\cimv2\power", "SELECT InstanceID FROM Win32_PowerPlan WHERE InstanceID !='" + _activePowerScheme + "'").Get())- _serchScheme = Convert.ToString(managementObj["InstanceID"]);- });+ string _activePowerScheme = @"Microsoft:PowerPlan\\{" + Registry.LocalMachine.OpenSubKey(@"SYSTEM\CurrentControlSet\Control\Power\User\PowerSchemes").GetValue("ActivePowerScheme").ToString() + "}";- _serchScheme = Regex.Match(_serchScheme, @"\{([^)]*)\}").Groups[1].Value;+ Parallel.Invoke(() =>+ {+ foreach (var managementObj in new ManagementObjectSearcher(@"root\cimv2\power", "SELECT InstanceID FROM Win32_PowerPlan WHERE InstanceID !='" + _activePowerScheme + "'").Get())+ _serchScheme = Convert.ToString(managementObj["InstanceID"]);+ });- using (_powercfg)- {- _powercfg.StartInfo.Arguments = $"/setactive {_serchScheme}";- _powercfg.Start();+ _serchScheme = Regex.Match(_serchScheme, @"\{([^)]*)\}").Groups[1].Value;++ using (_powercfg)+ {+ _powercfg.StartInfo.Arguments = $"/setactive {_serchScheme}";+ _powercfg.Start();+ }}}- }- catch (Exception ex) { Debug.WriteLine(ex.Message.ToString()); }-+ catch (Exception ex) { Debug.WriteLine(ex.Message.ToString()); }+ })+ { IsBackground = true };+ _thread.Start();}}}diff --git a/.Source/GTweak/Utilities/ViewNotification.cs b/.Source/GTweak/Utilities/ViewNotification.csindex 7b75d503..ec4864a5 100644--- a/.Source/GTweak/Utilities/ViewNotification.cs+++ b/.Source/GTweak/Utilities/ViewNotification.cs@@ -16,17 +16,17 @@ namespace GTweak.Utilities{if (Settings.IsViewNotification){- new Thread(() => new Settings().RunAnalysis()).Start();- new Thread(() => new Settings().RunAnalysis()).IsBackground = true;+ Thread _thread = new Thread(() => new Settings().RunAnalysis()) { IsBackground = true };+ _thread.Start();await Task.Delay(300);- Application.Current.Dispatcher.Invoke(() =>+ Application.Current.Dispatcher.Invoke(delegate{- NotificationWindow notificationWindow = new NotificationWindow();-- Parallel.Invoke(async () =>+ Parallel.Invoke(async delegate{+ NotificationWindow notificationWindow = new NotificationWindow();+if (notificationWindow.IsLoaded || isAlreadyLaunch)return;@@ -40,8 +40,7 @@ namespace GTweak.Utilities};await Task.Delay(100);notificationWindow.Show();- notificationWindow.Closed += (s, e) => { isAlreadyLaunch = false; };-+ notificationWindow.Closed += delegate { isAlreadyLaunch = false; };});});}@@ -49,7 +48,7 @@ namespace GTweak.Utilitiesinternal void CheckingTempFile(){- if (File.Exists(Settings.PathIcon) == false)+ if (!File.Exists(Settings.PathIcon)){byte[] _iconByte = default;using (MemoryStream fileOut = new MemoryStream(Resources.GTweak))@@ -63,7 +62,7 @@ namespace GTweak.UtilitiesFile.WriteAllBytes(Settings.PathIcon, _iconByte);}- if (File.Exists(Settings.PathSound) == false)+ if (!File.Exists(Settings.PathSound)){byte[] _soundbyte = default;using (MemoryStream fileOut = new MemoryStream(Resources.Sound))diff --git a/.Source/GTweak/Windows/NotificationWindow.xaml.cs b/.Source/GTweak/Windows/NotificationWindow.xaml.csindex 053cb8c9..76ea87c5 100644--- a/.Source/GTweak/Windows/NotificationWindow.xaml.cs+++ b/.Source/GTweak/Windows/NotificationWindow.xaml.cs@@ -7,7 +7,6 @@ using System.Windows.Controls;using System.Windows.Input;using System.Windows.Media;using System.Windows.Media.Animation;-using System.Windows.Media.Imaging;using System.Windows.Threading;namespace GTweak.Windows@@ -27,7 +26,7 @@ namespace GTweak.Windows{InitializeComponent();- ImageBody.Source ??= new BitmapImage(new Uri(Settings.PathIcon));+ ImageBody.Source ??= (ImageSource)new ImageSourceConverter().ConvertFromString(Settings.PathIcon);timer = new DispatcherTimer(new TimeSpan(0, 0, 1), DispatcherPriority.Normal, delegate{@@ -36,6 +35,8 @@ namespace GTweak.Windows}, Application.Current.Dispatcher);timer.Start();++ _mediaPlayer.Open(new Uri(Settings.PathSound));}private void BtnExit_PreviewMouseDown(object sender, MouseButtonEventArgs e)@@ -64,7 +65,6 @@ namespace GTweak.Windows{if (Settings.IsSoundNotification){- _mediaPlayer.Open(new Uri(Settings.PathSound));_mediaPlayer.Volume = Settings.VolumeNotification / 100.0f;_mediaPlayer.Play();}@@ -130,7 +130,7 @@ namespace GTweak.WindowsClosing -= Window_Closing;e.Cancel = true;DoubleAnimation doubleAnimation = new DoubleAnimation(0, TimeSpan.FromSeconds(0.1));- doubleAnimation.Completed += delegate { Close(); };+ doubleAnimation.Completed += delegate { _mediaPlayer.Close(); Close(); };Timeline.SetDesiredFrameRate(doubleAnimation, 400);BeginAnimation(OpacityProperty, doubleAnimation);}