Portable Tool for an Ideal Windows Setup
C# activatorbloatware-removalcsharpdebloatdebloaterdisable-servicesmonitoring-systemportableprivacy-toolsregistry-tweakssystem-tuningsystem-utilitytelemetrytweakerwindows-10windows-11windows-debloatwindows-defenderwindows-optimizationwindows-tweaks
add even more DNS server & re logging + clr
Greedeks7075513f9f50
diff --git a/.Source/GTweak/App.xaml.cs b/.Source/GTweak/App.xaml.csindex 8e7db304..1e2e4110 100644--- a/.Source/GTweak/App.xaml.cs+++ b/.Source/GTweak/App.xaml.cs@@ -22,7 +22,7 @@ namespace GTweak{InitializeComponent();- this.DispatcherUnhandledException += OnDispatcherUnhandledException;+ DispatcherUnhandledException += OnDispatcherUnhandledException;AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;}diff --git a/.Source/GTweak/Assets/UserControl/Card.xaml.cs b/.Source/GTweak/Assets/UserControl/Card.xaml.csindex dd90e038..11ca060c 100644--- a/.Source/GTweak/Assets/UserControl/Card.xaml.cs+++ b/.Source/GTweak/Assets/UserControl/Card.xaml.cs@@ -21,7 +21,7 @@ namespace GTweak.Assets.UserControlinternal static readonly DependencyProperty TextProperty =DependencyProperty.Register("DescriptionBlock", typeof(string), typeof(Card), new PropertyMetadata(string.Empty));- internal new static readonly DependencyProperty ContentProperty =+ internal static new readonly DependencyProperty ContentProperty =DependencyProperty.Register("BtnContent", typeof(string), typeof(Button), new PropertyMetadata(string.Empty, (s, e) => ((Button)s).Content = (string)e.NewValue));internal static readonly DependencyProperty ImageSourceProperty =diff --git a/.Source/GTweak/Utilities/Configuration/SystemDiagnostics.cs b/.Source/GTweak/Utilities/Configuration/SystemDiagnostics.csindex 6dbc28f2..157a0c66 100644--- a/.Source/GTweak/Utilities/Configuration/SystemDiagnostics.cs+++ b/.Source/GTweak/Utilities/Configuration/SystemDiagnostics.cs@@ -408,7 +408,9 @@ namespace GTweak.Utilities.Configurationstring name when name.StartsWith("fa") => "aparat.com",string name when name.StartsWith("zh") => "baidu.com",string name when name.StartsWith("ru") => "yandex.ru",+ string name when name.StartsWith("kk") => "yandex.kz",string name when name.StartsWith("ko") => "naver.com",+ string name when name.StartsWith("cs") => "seznam.cz",string name when name.StartsWith("tm") => "turkmenportal.com",string name when name.StartsWith("vn") => "coccoc.com",string name when name.StartsWith("cu") => "ecured.cu",@@ -419,7 +421,7 @@ namespace GTweak.Utilities.Configurationstring name when name.StartsWith("fr") => "orange.fr",string name when name.StartsWith("es") => "terra.es",string name when name.StartsWith("it") => "libero.it",- string name when name.StartsWith("tr") || name.StartsWith("in") => "bing.com",+ string name when name.StartsWith("tr") || name.StartsWith("in") || name.StartsWith("ar") => "bing.com",_ => "google.com"};diff --git a/.Source/GTweak/Utilities/Controls/ErrorLogging.cs b/.Source/GTweak/Utilities/Controls/ErrorLogging.csindex 81849848..f24960b5 100644--- a/.Source/GTweak/Utilities/Controls/ErrorLogging.cs+++ b/.Source/GTweak/Utilities/Controls/ErrorLogging.cs@@ -9,30 +9,26 @@ namespace GTweak.Utilities.Controls{internal class ErrorLogging{- private static readonly string _logFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "GTweak_Error.log");+ [Conditional("DEBUG")]+ internal static void LogDebug(Exception ex, [CallerMemberName] string memberName = "") => Debug.WriteLine($"Debug: {ex.Message}\nStack Trace: {ex.StackTrace}\nMember: {memberName}\n");internal static void LogWritingFile(Exception ex, [CallerMemberName] string memberName = "") => Task.Run(() => LogToFile(ex, memberName)).Wait();- internal static void LogDebug(Exception ex, [CallerMemberName] string memberName = "") => Debug.WriteLine($"Debug: {ex.Message}\nStack Trace: {ex.StackTrace}\nMember: {memberName}\n");-private static async Task LogToFile(Exception ex, string memberName){try{- using var stream = new FileStream(_logFilePath, FileMode.Append, FileAccess.Write, FileShare.Read);+ using var stream = new FileStream(StoragePaths.LogFile, FileMode.OpenOrCreate, FileAccess.Write, FileShare.Read);using var writer = new StreamWriter(stream, new UTF8Encoding(false));await writer.WriteLineAsync($"[{DateTime.Now}]\nMember: {memberName}\nError: {ex.Message}\nStack Trace:\n{ex.StackTrace}\n");await writer.FlushAsync();Process.Start(new ProcessStartInfo{- FileName = _logFilePath,+ FileName = StoragePaths.LogFile,UseShellExecute = true});}- catch (Exception fileEx)- {- LogDebug(fileEx);- }+ catch (Exception fileEx) { LogDebug(fileEx); }}}}\ No newline at end of filediff --git a/.Source/GTweak/Utilities/Controls/SettingsRepository.cs b/.Source/GTweak/Utilities/Controls/SettingsRepository.csindex c4084390..e5e798dd 100644--- a/.Source/GTweak/Utilities/Controls/SettingsRepository.cs+++ b/.Source/GTweak/Utilities/Controls/SettingsRepository.cs@@ -20,6 +20,7 @@ namespace GTweak.Utilities.Controlsinternal static string HostsFile => Path.Combine(Environment.SystemDirectory, @"drivers\etc\hosts");internal static string PowFile => Path.Combine(FolderLocation, "UltimatePerformance.pow");internal static string IconBlank => Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows), "Blank.ico");+ internal static string LogFile => Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "GTweak_Error.log");internal static string RegistryLocation => @"HKEY_CURRENT_USER\Software\GTweak";}@@ -48,7 +49,7 @@ namespace GTweak.Utilities.Controls{ "HiddenIP", () => IsHiddenIpAddress = RegistryHelp.GetValue(StoragePaths.RegistryLocation, "HiddenIP", IsHiddenIpAddress) }};- internal static readonly Dictionary<string, object> defaultRegValues = new Dictionary<string, object>+ internal static readonly Dictionary<string, object> registryDefaults = new Dictionary<string, object>{{ "Notification", true },{ "Update", true },@@ -60,20 +61,20 @@ namespace GTweak.Utilities.Controls{ "HiddenIP", true }};- internal static bool IsViewNotification { get => (bool)defaultRegValues["Notification"]; set => defaultRegValues["Notification"] = value; }- internal static bool IsUpdateCheckRequired { get => (bool)defaultRegValues["Update"]; set => defaultRegValues["Update"] = value; }- internal static bool IsTopMost { get => (bool)defaultRegValues["TopMost"]; set => defaultRegValues["TopMost"] = value; }- internal static bool IsPlayingSound { get => (bool)defaultRegValues["Sound"]; set => defaultRegValues["Sound"] = value; }- internal static int Volume { get => (int)defaultRegValues["Volume"]; set => defaultRegValues["Volume"] = value; }- internal static string Language { get => (string)defaultRegValues["Language"]; set => defaultRegValues["Language"] = value; }- internal static string Theme { get => (string)defaultRegValues["Theme"]; set => defaultRegValues["Theme"] = value; }- internal static bool IsHiddenIpAddress { get => (bool)defaultRegValues["HiddenIP"]; set => defaultRegValues["HiddenIP"] = value; }+ internal static bool IsViewNotification { get => (bool)registryDefaults["Notification"]; set => registryDefaults["Notification"] = value; }+ internal static bool IsUpdateCheckRequired { get => (bool)registryDefaults["Update"]; set => registryDefaults["Update"] = value; }+ internal static bool IsTopMost { get => (bool)registryDefaults["TopMost"]; set => registryDefaults["TopMost"] = value; }+ internal static bool IsPlayingSound { get => (bool)registryDefaults["Sound"]; set => registryDefaults["Sound"] = value; }+ internal static int Volume { get => (int)registryDefaults["Volume"]; set => registryDefaults["Volume"] = value; }+ internal static string Language { get => (string)registryDefaults["Language"]; set => registryDefaults["Language"] = value; }+ internal static string Theme { get => (string)registryDefaults["Theme"]; set => registryDefaults["Theme"] = value; }+ internal static bool IsHiddenIpAddress { get => (bool)registryDefaults["HiddenIP"]; set => registryDefaults["HiddenIP"] = value; }internal void СheckingParameters(){bool isRegistryEmpty = false;- foreach (string key in defaultRegValues.Keys)+ foreach (string key in registryDefaults.Keys){if (RegistryHelp.ValueExists(StoragePaths.RegistryLocation, key)){@@ -84,7 +85,7 @@ namespace GTweak.Utilities.Controlsif (isRegistryEmpty){- foreach (var subkey in defaultRegValues)+ foreach (var subkey in registryDefaults)RegistryHelp.Write(Registry.CurrentUser, @"Software\GTweak", subkey.Key, subkey.Value, RegistryValueKind.String);}elsediff --git a/.Source/GTweak/Utilities/Helpers/TrustedInstaller.cs b/.Source/GTweak/Utilities/Helpers/TrustedInstaller.csindex 4e37a169..a99bb0f3 100644--- a/.Source/GTweak/Utilities/Helpers/TrustedInstaller.cs+++ b/.Source/GTweak/Utilities/Helpers/TrustedInstaller.cs@@ -50,19 +50,19 @@ namespace GTweak.Utilities.Helpers[return: MarshalAs(UnmanagedType.Bool)]private static extern bool InitializeProcThreadAttributeList(IntPtr lpAttributeList, int dwAttributeCount, int dwFlags, ref IntPtr lpSize);- const uint MAXIMUM_ALLOWED = 0x02000000;-- const uint SC_MANAGER_CONNECT = 0x0001;- const uint SC_MANAGER_ENUMERATE_SERVICE = 0x0004;- const uint SC_MANAGER_QUERY_LOCK_STATUS = 0x0010;- const uint SERVICE_QUERY_STATUS = 0x0004;- const uint SERVICE_START = 0x0010;- const int SC_STATUS_PROCESS_INFO = 0;- const string ServicesActiveDatabase = "ServicesActive";-- const int PROC_THREAD_ATTRIBUTE_PARENT_PROCESS = 0x00020000;- const uint EXTENDED_STARTUPINFO_PRESENT = 0x00080000;- const uint CREATE_NO_WINDOW = 0x08000000;+ private const uint MAXIMUM_ALLOWED = 0x02000000;++ private const uint SC_MANAGER_CONNECT = 0x0001;+ private const uint SC_MANAGER_ENUMERATE_SERVICE = 0x0004;+ private const uint SC_MANAGER_QUERY_LOCK_STATUS = 0x0010;+ private const uint SERVICE_QUERY_STATUS = 0x0004;+ private const uint SERVICE_START = 0x0010;+ private const int SC_STATUS_PROCESS_INFO = 0;+ private const string ServicesActiveDatabase = "ServicesActive";++ private const int PROC_THREAD_ATTRIBUTE_PARENT_PROCESS = 0x00020000;+ private const uint EXTENDED_STARTUPINFO_PRESENT = 0x00080000;+ private const uint CREATE_NO_WINDOW = 0x08000000;[StructLayout(LayoutKind.Sequential)]private struct SECURITY_ATTRIBUTESdiff --git a/.Source/GTweak/Windows/LoadingWindow.xaml.cs b/.Source/GTweak/Windows/LoadingWindow.xaml.csindex 4fbf934f..97697553 100644--- a/.Source/GTweak/Windows/LoadingWindow.xaml.cs+++ b/.Source/GTweak/Windows/LoadingWindow.xaml.cs@@ -34,7 +34,7 @@ namespace GTweak.Windows{new TypewriterAnimation((string)FindResource("text6_load"), TextLoad, TimeSpan.FromMilliseconds(300));await Task.Delay(310);- this.Close();+ Close();new MainWindow().Show();};backgroundWorker.RunWorkerAsync();@@ -86,8 +86,8 @@ namespace GTweak.WindowsClosing -= Window_Closing;e.Cancel = true;DoubleAnimation doubleAnim = new DoubleAnimation(0, TimeSpan.FromSeconds(0.1));- doubleAnim.Completed += delegate { this.Close(); };- this.BeginAnimation(OpacityProperty, doubleAnim);+ doubleAnim.Completed += delegate { Close(); };+ BeginAnimation(OpacityProperty, doubleAnim);}}}diff --git a/.Source/GTweak/Windows/MainWindow.xaml.cs b/.Source/GTweak/Windows/MainWindow.xaml.csindex a4360660..eb0e68fc 100644--- a/.Source/GTweak/Windows/MainWindow.xaml.cs+++ b/.Source/GTweak/Windows/MainWindow.xaml.cs@@ -30,7 +30,7 @@ namespace GTweakThemeSelectionMenu.SelectedIndex = GetSelectedIndex(SettingsRepository.Theme, "Dark", SettingsRepository.AvailableThemes);App.ImportTweaksUpdate += delegate { BtnMore.IsChecked = true; };- App.ThemeChanged += delegate { this.Close(); new RebootWindow().ShowDialog(); };+ App.ThemeChanged += delegate { Close(); new RebootWindow().ShowDialog(); };}private int GetSelectedIndex(string value, string defaultValue, params string[] listing)@@ -90,14 +90,14 @@ namespace GTweakSettingsMenuAnimation();}- private void ButtonMinimized_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e) => this.WindowState = WindowState.Minimized;+ private void ButtonMinimized_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e) => WindowState = WindowState.Minimized;private void ButtonExit_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e){switch (SystemTweaks.isTweakWorkingAntivirus){case false:- this.Close();+ Close();break;case true:new ViewNotification().Show("", "warn", "windefclose_notification");@@ -116,7 +116,7 @@ namespace GTweakClosing -= Window_Closing;e.Cancel = true;DoubleAnimation doubleAnim = new DoubleAnimation(0, (Duration)TimeSpan.FromSeconds(0.1));- doubleAnim.Completed += delegate { this.Close(); };+ doubleAnim.Completed += delegate { Close(); };Timeline.SetDesiredFrameRate(doubleAnim, 400);BeginAnimation(OpacityProperty, doubleAnim);}diff --git a/.Source/GTweak/Windows/NotificationWindow.xaml.cs b/.Source/GTweak/Windows/NotificationWindow.xaml.csindex 358d9b74..1bc985a6 100644--- a/.Source/GTweak/Windows/NotificationWindow.xaml.cs+++ b/.Source/GTweak/Windows/NotificationWindow.xaml.cs@@ -27,7 +27,7 @@ namespace GTweak.Windowstimer = new DispatcherTimer(new TimeSpan(0, 0, 1), DispatcherPriority.Normal, delegate{- if (time == TimeSpan.Zero) { timer.Stop(); this.Close(); }+ if (time == TimeSpan.Zero) { timer.Stop(); Close(); }time = time.Add(TimeSpan.FromSeconds(-1));}, Application.Current.Dispatcher);@@ -37,7 +37,7 @@ namespace GTweak.Windowsprivate void BtnExit_PreviewMouseDown(object sender, MouseButtonEventArgs e){if (e.LeftButton == MouseButtonState.Pressed)- this.Close();+ Close();}private void ActionSelection_PreviewMouseDown(object sender, MouseButtonEventArgs e)diff --git a/.Source/GTweak/Windows/UpdateWindow.xaml.cs b/.Source/GTweak/Windows/UpdateWindow.xaml.csindex c5496029..4090ddb4 100644--- a/.Source/GTweak/Windows/UpdateWindow.xaml.cs+++ b/.Source/GTweak/Windows/UpdateWindow.xaml.cs@@ -43,7 +43,7 @@ namespace GTweak.WindowsClosing -= Window_Closing;e.Cancel = true;DoubleAnimation doubleAnim = new DoubleAnimation(0, (Duration)TimeSpan.FromSeconds(0.1));- doubleAnim.Completed += delegate { this.Close(); };+ doubleAnim.Completed += delegate { Close(); };Timeline.SetDesiredFrameRate(doubleAnim, 400);BeginAnimation(OpacityProperty, doubleAnim);}@@ -51,7 +51,7 @@ namespace GTweak.Windowsprivate void BtnExit_PreviewMouseDown(object sender, MouseButtonEventArgs e){if (e.LeftButton == MouseButtonState.Pressed)- this.Close();+ Close();}private void BtnLog_PreviewMouseDown(object sender, MouseButtonEventArgs e)@@ -83,7 +83,7 @@ namespace GTweak.Windows}catch{- this.Close();+ Close();new ViewNotification().Show("", "warn", "warn_update_notification");}}diff --git a/.Source/GTweak/Windows/WaitingWindow.xaml.cs b/.Source/GTweak/Windows/WaitingWindow.xaml.csindex 5c8efc84..3658688d 100644--- a/.Source/GTweak/Windows/WaitingWindow.xaml.cs+++ b/.Source/GTweak/Windows/WaitingWindow.xaml.cs@@ -29,7 +29,7 @@ namespace GTweak.WindowsProcessModule objCurrentModule = Process.GetCurrentProcess().MainModule;disablingWinKeys.objKeyboardProcess = new DisablingWinKeys.LowLevelKeyboardProc(disablingWinKeys.CaptureKey);disablingWinKeys.ptrHook = DisablingWinKeys.SetWindowsHookEx(13, disablingWinKeys.objKeyboardProcess, DisablingWinKeys.GetModuleHandle(objCurrentModule.ModuleName), 1);- this.Close();+ Close();};Timeline.SetDesiredFrameRate(doubleAnim, 400);BeginAnimation(OpacityProperty, doubleAnim);