Skip to content

Portable Tool for an Ideal Windows Setup

-unlock attribute powercfg (max cpu frequency) -error output to the console in the (try catch) construction

Greedeks1b7ace235f63
diff --git a/.Source/GTweak/Utilities/Helpers/RegistryHelp.cs b/.Source/GTweak/Utilities/Helpers/RegistryHelp.cs
index bce720d8..f7c69070 100644
--- a/.Source/GTweak/Utilities/Helpers/RegistryHelp.cs
+++ b/.Source/GTweak/Utilities/Helpers/RegistryHelp.cs
@@ -1,4 +1,6 @@
using Microsoft.Win32;
+using System.Diagnostics;
+using System;
namespace GTweak.Utilities.Helpers
{
@@ -7,24 +9,24 @@ namespace GTweak.Utilities.Helpers
internal static void DeleteFolderTree(in RegistryKey _registrykey, in string _subkey)
{
if (_registrykey.OpenSubKey(_subkey) != null)
- try { _registrykey.DeleteSubKeyTree(_subkey); } catch { }
+ try { _registrykey.DeleteSubKeyTree(_subkey); } catch (Exception ex) { Debug.WriteLine(ex.Message.ToString()); }
}
internal static void DeleteValue(in RegistryKey _registrykey, in string _subkey, in string _value)
{
if (_registrykey.OpenSubKey(_subkey) != null && _registrykey.OpenSubKey(_subkey)?.GetValue(_value, null) != null)
- try { _registrykey.OpenSubKey(_subkey, true)?.DeleteValue(_value); } catch { };
+ try { _registrykey.OpenSubKey(_subkey, true)?.DeleteValue(_value); } catch (Exception ex) { Debug.WriteLine(ex.Message.ToString()); }
}
internal static void Write<T>(in RegistryKey _registrykey, in string _key, in string _name, in T _data, in RegistryValueKind _kind)
{
- try { _registrykey.CreateSubKey(_key, true)?.SetValue(_name, _data, _kind); } catch { }
+ try { _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 { }
+ try { _registrykey.CreateSubKey(_subkey); } catch (Exception ex) { Debug.WriteLine(ex.Message.ToString()); }
}
internal static void DeleteRegristyTree(in RegistryKey _registrykey, in string _key)
@@ -41,13 +43,13 @@ namespace GTweak.Utilities.Helpers
{
_registryFolder.DeleteValue(value);
}
- catch { }
+ catch (Exception ex) { Debug.WriteLine(ex.Message.ToString()); }
}
}
Registry.LocalMachine.DeleteSubKeyTree(_key, false);
}
- catch { }
+ catch (Exception ex) { Debug.WriteLine(ex.Message.ToString()); }
}
}
}
diff --git a/.Source/GTweak/Utilities/Settings.cs b/.Source/GTweak/Utilities/Settings.cs
index 5fc5e4f5..985337ec 100644
--- a/.Source/GTweak/Utilities/Settings.cs
+++ b/.Source/GTweak/Utilities/Settings.cs
@@ -137,7 +137,8 @@ namespace GTweak.Utilities
foreach (KeyValuePair<string,string> addSystem in СonfigSettings.configSystem)
settingsFileINI.WriteConfig("System Tweaks", addSystem.Key, addSystem.Value);
- } catch { }
+ }
+ catch (Exception ex) { Debug.WriteLine(ex.Message.ToString()); }
}
}
@@ -179,7 +180,7 @@ namespace GTweak.Utilities
FileName = "cmd.exe"
});
}
- catch { }
+ catch (Exception ex) { Debug.WriteLine(ex.Message.ToString()); }
}
}
}
diff --git a/.Source/GTweak/Utilities/Tweaks/ClearingMemory.cs b/.Source/GTweak/Utilities/Tweaks/ClearingMemory.cs
index f32398f8..78c3c7dc 100644
--- a/.Source/GTweak/Utilities/Tweaks/ClearingMemory.cs
+++ b/.Source/GTweak/Utilities/Tweaks/ClearingMemory.cs
@@ -160,7 +160,7 @@ namespace GTweak.Utilities.Tweaks
}
}
}
- catch { }
+ catch (Exception ex) { Debug.WriteLine(ex.Message.ToString()); }
}
private static bool SetIncreasePrivilege(string privilegeName)
diff --git a/.Source/GTweak/Utilities/Tweaks/ConfidentialityTweaks.cs b/.Source/GTweak/Utilities/Tweaks/ConfidentialityTweaks.cs
index 90bcf12a..4dfc8308 100644
--- a/.Source/GTweak/Utilities/Tweaks/ConfidentialityTweaks.cs
+++ b/.Source/GTweak/Utilities/Tweaks/ConfidentialityTweaks.cs
@@ -1,6 +1,8 @@
using GTweak.Utilities.Helpers;
using GTweak.View;
using Microsoft.Win32;
+using System.Diagnostics;
+using System;
using System.IO;
using System.IO.Compression;
using System.Threading;
@@ -336,7 +338,7 @@ namespace GTweak.Utilities.Tweaks
RegistryHelp.DeleteValue(Registry.LocalMachine, @"SOFTWARE\Policies\Microsoft\Windows\DataCollection", "AllowDeviceNameInTelemetry");
RegistryHelp.Write(Registry.CurrentUser, @"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "Start_TrackProgs", 1, RegistryValueKind.DWord);
}
- catch { };
+ catch (Exception ex) { Debug.WriteLine(ex.Message.ToString()); }
}
break;
case "TglButton7":
@@ -364,7 +366,8 @@ namespace GTweak.Utilities.Tweaks
{
BlockSpyDomain(isChoose);
- try { File.Delete(Settings.PathSystemDisk + @"\Windows\System32\drivers\etc\hosts (Default GTweak)"); } catch { }
+ try { File.Delete(Settings.PathSystemDisk + @"\Windows\System32\drivers\etc\hosts (Default GTweak)"); }
+ catch (Exception ex) { Debug.WriteLine(ex.Message.ToString()); }
File.Move(Settings.PathSystemDisk + @"\Windows\System32\drivers\etc\hosts", Settings.PathSystemDisk + @"\Windows\System32\drivers\etc\hosts (Default GTweak)");
@@ -386,7 +389,7 @@ namespace GTweak.Utilities.Tweaks
File.Copy(Settings.PathSystemDisk + @"\Windows\System32\drivers\etc\hosts (Default GTweak)", Settings.PathSystemDisk + @"\Windows\System32\drivers\etc\hosts", true);
File.Delete(Settings.PathSystemDisk + @"\Windows\System32\drivers\etc\hosts (Default GTweak)");
}
- catch { }
+ catch (Exception ex) { Debug.WriteLine(ex.Message.ToString()); }
}
break;
case "TglButton10":
diff --git a/.Source/GTweak/Utilities/Tweaks/Firewall.cs b/.Source/GTweak/Utilities/Tweaks/Firewall.cs
index c76770bf..38fc35f7 100644
--- a/.Source/GTweak/Utilities/Tweaks/Firewall.cs
+++ b/.Source/GTweak/Utilities/Tweaks/Firewall.cs
@@ -1,5 +1,6 @@
using NetFwTypeLib;
using System;
+using System.Diagnostics;
using System.Threading.Tasks;
using System.Windows;
@@ -32,8 +33,8 @@ namespace GTweak.Utilities.Tweaks
}
else
{
- try { RulesUpdateIN(isChoose); } catch { }
- try { RulesUpdateOUT(isChoose); } catch { }
+ try { RulesUpdateIN(isChoose); } catch (Exception ex) { Debug.WriteLine(ex.Message.ToString()); }
+ try { RulesUpdateOUT(isChoose); } catch (Exception ex) { Debug.WriteLine(ex.Message.ToString()); }
}
}
catch { new ViewNotification().Show("", (string)Application.Current.Resources["title0_notification"], (string)Application.Current.Resources["firewalloff_notification"]); }
@@ -168,7 +169,7 @@ namespace GTweak.Utilities.Tweaks
RulesHosts(isCheck);
else
{
- try { RulesHosts(isCheck); } catch { }
+ try { RulesHosts(isCheck); } catch (Exception ex) { Debug.WriteLine(ex.Message.ToString()); }
}
}
catch { new ViewNotification().Show("", (string)Application.Current.Resources["title0_notification"], (string)Application.Current.Resources["firewalloff_notification"]); }
diff --git a/.Source/GTweak/Utilities/Tweaks/InterfaceTweaks.cs b/.Source/GTweak/Utilities/Tweaks/InterfaceTweaks.cs
index 303a19fc..1823e153 100644
--- a/.Source/GTweak/Utilities/Tweaks/InterfaceTweaks.cs
+++ b/.Source/GTweak/Utilities/Tweaks/InterfaceTweaks.cs
@@ -312,7 +312,7 @@ namespace GTweak.Utilities.Tweaks
process.Start();
}
}
- catch { }
+ catch (Exception ex) { Debug.WriteLine(ex.Message.ToString()); }
finally
{
Process[] explorer = Process.GetProcessesByName("explorer");
@@ -446,7 +446,7 @@ namespace GTweak.Utilities.Tweaks
RegistryHelp.DeleteFolderTree(Registry.LocalMachine, @"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Icons");
}
}
- catch { };
+ catch (Exception ex) { Debug.WriteLine(ex.Message.ToString()); };
break;
case "TglButton12":
if (isChoose)
diff --git a/.Source/GTweak/Utilities/Tweaks/SystemTweaks.cs b/.Source/GTweak/Utilities/Tweaks/SystemTweaks.cs
index f27af24c..e8115067 100644
--- a/.Source/GTweak/Utilities/Tweaks/SystemTweaks.cs
+++ b/.Source/GTweak/Utilities/Tweaks/SystemTweaks.cs
@@ -125,7 +125,7 @@ namespace GTweak.Utilities.Tweaks
}
}
}
- catch { }
+ catch (Exception ex) { Debug.WriteLine(ex.Message.ToString()); }
if (Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\MicrosoftEdge\PhishingFilter", "EnabledV9", null) == null ||
@@ -310,7 +310,7 @@ namespace GTweak.Utilities.Tweaks
isNetshState = getStateNetsh.Contains("default");
}
- catch { }
+ catch (Exception ex) { Debug.WriteLine(ex.Message.ToString()); }
});
}
@@ -433,7 +433,7 @@ namespace GTweak.Utilities.Tweaks
keychange?.SetValue("PerformanceIdleTime", _dataTime, RegistryValueKind.Binary);
}
}
- } catch { }
+ } catch (Exception ex) { Debug.WriteLine(ex.Message.ToString()); }
break;
case "TglButton8":
BackgroundWorker backgroundWorker = new BackgroundWorker();
@@ -754,7 +754,15 @@ namespace GTweak.Utilities.Tweaks
}
}
}
- catch { }
+ catch (Exception ex) { Debug.WriteLine(ex.Message.ToString()); }
+ finally
+ {
+ using (_powercfg)
+ {
+ _powercfg.StartInfo.Arguments = @"-attributes SUB_PROCESSOR 75b0ae3f-bce0-45a7-8c89-c9611c25e100 -ATTRIB_HIDE";
+ _powercfg.Start();
+ }
+ }
}
}
diff --git a/.Source/GTweak/Utilities/Tweaks/UninstallingApps.cs b/.Source/GTweak/Utilities/Tweaks/UninstallingApps.cs
index ddfc11eb..d01eb3a6 100644
--- a/.Source/GTweak/Utilities/Tweaks/UninstallingApps.cs
+++ b/.Source/GTweak/Utilities/Tweaks/UninstallingApps.cs
@@ -159,7 +159,7 @@ namespace GTweak.Utilities.Tweaks
else if (_appName == "OneDrive")
DeletedOneDrive();
}
- catch { }
+ catch (Exception ex) { Debug.WriteLine(ex.Message.ToString()); }
}
internal static void DeletedApp_All()
@@ -193,7 +193,7 @@ namespace GTweak.Utilities.Tweaks
CortanaTweak(true);
DeletedOneDrive();
}
- catch { }
+ catch (Exception ex) { Debug.WriteLine(ex.Message.ToString()); }
}
diff --git a/.Source/GTweak/Utilities/Tweaks/WindowsDefender.cs b/.Source/GTweak/Utilities/Tweaks/WindowsDefender.cs
index cc404a36..25c8c1c5 100644
--- a/.Source/GTweak/Utilities/Tweaks/WindowsDefender.cs
+++ b/.Source/GTweak/Utilities/Tweaks/WindowsDefender.cs
@@ -299,15 +299,12 @@ namespace GTweak.Utilities.Tweaks
"reg add HKLM\\SYSTEM\\CurrentControlSet\\Services\\WinDefend /t REG_DWORD /v Start /d 4 /f");
}
- private void KillProcess(string Processname)
+ private void KillProcess(string getName)
{
- foreach (Process proc in Process.GetProcessesByName(Processname))
+ foreach (Process _process in Process.GetProcessesByName(getName))
{
- try
- {
- proc.Kill();
- }
- catch { }
+ try { _process.Kill();}
+ catch (Exception ex) { Debug.WriteLine(ex.Message.ToString()); }
}
}
@@ -330,7 +327,7 @@ namespace GTweak.Utilities.Tweaks
return comandoAEjecutar.StandardOutput.ReadToEnd();
}
- catch { }
+ catch (Exception ex) { Debug.WriteLine(ex.Message.ToString()); }
return null;
}
@@ -350,7 +347,7 @@ namespace GTweak.Utilities.Tweaks
foreach (FileInfo file in dir.GetFiles())
{
try { file.Delete(); }
- catch { }
+ catch (Exception ex) { Debug.WriteLine(ex.Message.ToString()); }
}
foreach (DirectoryInfo subDir in dir.GetDirectories())
@@ -375,7 +372,7 @@ namespace GTweak.Utilities.Tweaks
foreach (var defenderServ in defenderConfigDefault)
{
try { Registry.LocalMachine.OpenSubKey(@"SYSTEM\CurrentControlSet\Services\" + defenderServ.Key, true)?.SetValue("Start", 4, RegistryValueKind.DWord); }
- catch { }
+ catch (Exception ex) { Debug.WriteLine(ex.Message.ToString()); }
}
}
@@ -384,7 +381,7 @@ namespace GTweak.Utilities.Tweaks
foreach (var defenderServ in defenderConfigDefault)
{
try { Registry.LocalMachine.OpenSubKey(@"SYSTEM\CurrentControlSet\Services\" + defenderServ.Key, true)?.SetValue("Start", defenderConfigDefault.Values, RegistryValueKind.DWord); }
- catch { }
+ catch (Exception ex) { Debug.WriteLine(ex.Message.ToString()); }
}
}
diff --git a/.Source/GTweak/View/MoreView.xaml.cs b/.Source/GTweak/View/MoreView.xaml.cs
index 60960f95..0a52c109 100644
--- a/.Source/GTweak/View/MoreView.xaml.cs
+++ b/.Source/GTweak/View/MoreView.xaml.cs
@@ -1,6 +1,8 @@
using GTweak.Utilities;
using GTweak.Utilities.Tweaks;
+using System;
using System.ComponentModel;
+using System.Diagnostics;
using System.Threading.Tasks;
using System.Windows.Controls;
using System.Windows.Input;
@@ -80,7 +82,7 @@ namespace GTweak.View
BackgroundWorker backgroundWorker = new BackgroundWorker();
backgroundWorker.DoWork += (_s, _e) =>
{
- try { RecoveryPoint.DisablePoint(); } catch { }
+ try { RecoveryPoint.DisablePoint(); } catch (Exception ex) { Debug.WriteLine(ex.Message.ToString()); }
};
backgroundWorker.RunWorkerCompleted += (_s, _e) =>
{
diff --git a/.Source/GTweak/Windows/MessageWindow.xaml.cs b/.Source/GTweak/Windows/MessageWindow.xaml.cs
index 63f2810b..a5334748 100644
--- a/.Source/GTweak/Windows/MessageWindow.xaml.cs
+++ b/.Source/GTweak/Windows/MessageWindow.xaml.cs
@@ -1,5 +1,6 @@
using System;
using System.ComponentModel;
+using System.Diagnostics;
using System.Text.RegularExpressions;
using System.Windows;
using System.Windows.Input;
@@ -28,7 +29,7 @@ namespace GTweak.Windows
time = time.Add(TimeSpan.FromSeconds(-1));
}, Application.Current.Dispatcher);
- } catch { }
+ } catch (Exception ex) { Debug.WriteLine(ex.Message.ToString()); }
timer?.Start();
if (isViolationSystem)