Skip to content

Portable Tool for an Ideal Windows Setup

fix crash on startup caused by unsafe parallel hardware queries & fixed disabling the defragmentation tweak deb v 5.4.1

Greedeks77e85282f973
diff --git a/.Source/GTweak/App.xaml.cs b/.Source/GTweak/App.xaml.cs
index a23a10b1..d17d8991 100644
--- a/.Source/GTweak/App.xaml.cs
+++ b/.Source/GTweak/App.xaml.cs
@@ -73,7 +73,7 @@ namespace GTweak
private async void OnHandleDevicesEvents(MonitoringService.DeviceType deviceType)
{
BackgroundQueue backgroundQueue = new BackgroundQueue();
- await backgroundQueue.QueueTask(delegate { _systemDiagnostics.UpdatingDevicesData(deviceType); });
+ await backgroundQueue.QueueTask(delegate { _systemDiagnostics.RefreshDevicesData(deviceType); });
}
private static Uri GetResourceUri(string folder, bool isTheme = false) => isTheme ? new Uri($"Styles/Themes/{folder}/Colors.xaml", UriKind.Relative) : new Uri($"Languages/{folder}/Localize.xaml", UriKind.Relative);
diff --git a/.Source/GTweak/Properties/AssemblyInfo.cs b/.Source/GTweak/Properties/AssemblyInfo.cs
index c1f3133c..3600f3bb 100644
--- a/.Source/GTweak/Properties/AssemblyInfo.cs
+++ b/.Source/GTweak/Properties/AssemblyInfo.cs
@@ -7,9 +7,9 @@ using System.Windows;
[assembly: AssemblyProduct("GTweak")]
[assembly: AssemblyCopyright("� 2024-2026 Greedeks")]
[assembly: AssemblyTrademark("Greedeks")]
-[assembly: AssemblyInformationalVersion("Build: 5.4.0")]
-[assembly: AssemblyVersion("5.4.29.331")]
-[assembly: AssemblyFileVersion("5.4.29.331")]
+[assembly: AssemblyInformationalVersion("Build: 5.4.1")]
+[assembly: AssemblyVersion("5.4.45.64")]
+[assembly: AssemblyFileVersion("5.4.45.64")]
[assembly: ComVisible(false)]
diff --git a/.Source/GTweak/Properties/AssemblyInfo.tt b/.Source/GTweak/Properties/AssemblyInfo.tt
index 04632243..2d722ced 100644
--- a/.Source/GTweak/Properties/AssemblyInfo.tt
+++ b/.Source/GTweak/Properties/AssemblyInfo.tt
@@ -22,7 +22,7 @@ using System.Windows;
[assembly: AssemblyMetadata("RepositoryType", "git")]
<#+
- private const string majorVersion = "Build: 5.4.0";
+ private const string majorVersion = "Build: 5.4.1";
private string GenerateVersion()
{
diff --git a/.Source/GTweak/Utilities/Configuration/SystemDiagnostics.cs b/.Source/GTweak/Utilities/Configuration/SystemDiagnostics.cs
index 40503302..4fb55dd4 100644
--- a/.Source/GTweak/Utilities/Configuration/SystemDiagnostics.cs
+++ b/.Source/GTweak/Utilities/Configuration/SystemDiagnostics.cs
@@ -108,7 +108,7 @@ namespace GTweak.Utilities.Configuration
internal void GetHardwareData()
{
- Parallel.Invoke(() =>
+ Task.Run(() =>
{
try
{
@@ -117,50 +117,38 @@ namespace GTweak.Utilities.Configuration
isMsftAvailable = results?.Count > 0;
}
catch { isMsftAvailable = false; }
- });
- Parallel.Invoke(
- GetWallpaperImage,
- GetBiosInfo,
- GetMotherboardInfo,
- GetProcessorInfo,
- GetGraphicsInfo,
- GetMemoryInfo,
- GetUserIpAddress
- );
-
- UpdatingDevicesData();
+ Parallel.Invoke(
+ () => GetWallpaperImage(),
+ () => GetBiosInfo(),
+ () => GetMotherboardInfo(),
+ () => GetProcessorInfo(),
+ () => GetGraphicsInfo(),
+ () => GetMemoryInfo(),
+ () => RefreshDevicesData(),
+ () => GetUserIpAddress()
+ );
+ });
}
- internal void UpdatingDevicesData(DeviceType deviceType = DeviceType.All)
+ internal void RefreshDevicesData(DeviceType deviceType = DeviceType.All)
{
- string storage = string.Empty, audio = string.Empty, netAdapter = string.Empty;
+ if (deviceType == DeviceType.Storage || deviceType == DeviceType.All)
+ {
+ string value = GetStorageDevices();
+ Storage = value;
+ }
+
+ if (deviceType == DeviceType.Audio || deviceType == DeviceType.All)
+ {
+ string value = GetAudioDevices();
+ AudioDevice = value;
+ }
- switch (deviceType)
+ if (deviceType == DeviceType.Network || deviceType == DeviceType.All)
{
- case DeviceType.Storage:
- Parallel.Invoke(() => storage = GetStorageDevices());
- Storage = storage;
- break;
- case DeviceType.Audio:
- Parallel.Invoke(() => audio = GetAudioDevices());
- AudioDevice = audio;
- break;
- case DeviceType.Network:
- Parallel.Invoke(() => netAdapter = GetNetworkAdapters());
- NetworkAdapter = netAdapter;
- break;
- default:
- Parallel.Invoke
- (
- () => storage = GetStorageDevices(),
- () => audio = GetAudioDevices(),
- () => netAdapter = GetNetworkAdapters()
- );
- Storage = storage;
- AudioDevice = audio;
- NetworkAdapter = netAdapter;
- break;
+ string value = GetNetworkAdapters();
+ NetworkAdapter = value;
}
}
@@ -221,8 +209,12 @@ namespace GTweak.Utilities.Configuration
/// </summary>
private void GetBiosInfo()
{
- string output = CommandExecutor.GetCommandOutput(PathLocator.Executable.BcdEdit).GetAwaiter().GetResult();
- Bios.Mode = output.IndexOf("efi", StringComparison.OrdinalIgnoreCase) >= 0 ? "UEFI" : "Legacy Boot";
+ try
+ {
+ string output = CommandExecutor.GetCommandOutput(PathLocator.Executable.BcdEdit).GetAwaiter().GetResult();
+ Bios.Mode = output.IndexOf("efi", StringComparison.OrdinalIgnoreCase) >= 0 ? "UEFI" : "Legacy Boot";
+ }
+ catch { Bios.Mode = string.Empty; }
foreach (var managementObj in new ManagementObjectSearcher(@"root\cimv2", "select Name, Caption, Description, SMBIOSBIOSVersion, SerialNumber from Win32_BIOS", new EnumerationOptions { ReturnImmediately = true }).Get())
{
diff --git a/.Source/GTweak/Utilities/Helpers/CommandExecutor.cs b/.Source/GTweak/Utilities/Helpers/CommandExecutor.cs
index 2fae81ff..52e77d75 100644
--- a/.Source/GTweak/Utilities/Helpers/CommandExecutor.cs
+++ b/.Source/GTweak/Utilities/Helpers/CommandExecutor.cs
@@ -32,7 +32,8 @@ namespace GTweak.Utilities.Helpers
};
using Process process = new Process { StartInfo = startInfo };
- process.Start();
+ try { process.Start(); }
+ catch (Exception ex) { ErrorLogging.LogDebug(ex); }
string output = process.StandardOutput.ReadToEnd();
string error = process.StandardError.ReadToEnd();
diff --git a/.Source/GTweak/Utilities/Tweaks/SystemTweaks.cs b/.Source/GTweak/Utilities/Tweaks/SystemTweaks.cs
index 56b5c3c5..7450102f 100644
--- a/.Source/GTweak/Utilities/Tweaks/SystemTweaks.cs
+++ b/.Source/GTweak/Utilities/Tweaks/SystemTweaks.cs
@@ -194,14 +194,22 @@ namespace GTweak.Utilities.Tweaks
internal static void ViewNetshState()
{
- string getStateNetsh = CommandExecutor.GetCommandOutput("/c chcp 65001 & netsh int teredo show state & netsh int ipv6 isatap show state & netsh int isatap show state & netsh int ipv6 6to4 show state", false).Result;
- _isNetshState = getStateNetsh.Contains("default") || getStateNetsh.Contains("enabled");
+ try
+ {
+ string getStateNetsh = CommandExecutor.GetCommandOutput("/c chcp 65001 & netsh int teredo show state & netsh int ipv6 isatap show state & netsh int isatap show state & netsh int ipv6 6to4 show state", false).GetAwaiter().GetResult();
+ _isNetshState = getStateNetsh.Contains("default") || getStateNetsh.Contains("enabled");
+ }
+ catch { _isNetshState = false; }
}
internal static void ViewConfigTick()
{
- string output = CommandExecutor.GetCommandOutput(PathLocator.Executable.BcdEdit).Result;
- _isTickState = !Regex.IsMatch(output, @"(?is)(?=.*\bdisabledynamictick\s+(yes|true))(?=.*\buseplatformclock\s+(no|false))", RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture | RegexOptions.CultureInvariant);
+ try
+ {
+ string output = CommandExecutor.GetCommandOutput(PathLocator.Executable.BcdEdit).GetAwaiter().GetResult();
+ _isTickState = !Regex.IsMatch(output, @"(?is)(?=.*\bdisabledynamictick\s+(yes|true))(?=.*\buseplatformclock\s+(no|false))", RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture | RegexOptions.CultureInvariant);
+ }
+ catch { _isTickState = false; }
}
[DllImport("user32.dll")]
@@ -502,7 +510,7 @@ namespace GTweak.Utilities.Tweaks
break;
case "TglButton28":
SetTaskState(true, defragTask);
- RegistryHelp.Write(Registry.CurrentUser, @"""SOFTWARE\Microsoft\Dfrg\BootOptimizeFunction", "Enable", isDisabled ? "N" : "Y", RegistryValueKind.String);
+ RegistryHelp.Write(Registry.LocalMachine, @"SOFTWARE\Microsoft\Dfrg\BootOptimizeFunction", "Enable", isDisabled ? "N" : "Y", RegistryValueKind.String);
RegistryHelp.Write(Registry.LocalMachine, @"SYSTEM\CurrentControlSet\services\defragsvc", "Start", 2, RegistryValueKind.DWord);
break;
default:
diff --git a/.Source/GTweak/Utilities/Tweaks/UninstallingPakages.cs b/.Source/GTweak/Utilities/Tweaks/UninstallingPakages.cs
index f092f716..6953e832 100644
--- a/.Source/GTweak/Utilities/Tweaks/UninstallingPakages.cs
+++ b/.Source/GTweak/Utilities/Tweaks/UninstallingPakages.cs
@@ -103,10 +103,17 @@ namespace GTweak.Utilities.Tweaks
return false;
}
- internal async static void CheckingForLocalAccount()
+ internal static void CheckingForLocalAccount()
{
- string output = await CommandExecutor.GetCommandOutput("Get-LocalUser | Where-Object { $_.Enabled -match 'True'} | Select-Object -ExpandProperty PrincipalSource");
- _isLocalAccount = output.IndexOf("MicrosoftAccount", StringComparison.OrdinalIgnoreCase) < 0;
+ try
+ {
+ string output = CommandExecutor.GetCommandOutput("Get-LocalUser | Where-Object { $_.Enabled -match 'True'} | Select-Object -ExpandProperty PrincipalSource").GetAwaiter().GetResult();
+ _isLocalAccount = output.IndexOf("MicrosoftAccount", StringComparison.OrdinalIgnoreCase) < 0;
+ }
+ catch
+ {
+ _isLocalAccount = false;
+ }
}
internal static Task RestoreOneDriveFolder()
diff --git a/.Source/GTweak/Windows/LoadingWindow.xaml.cs b/.Source/GTweak/Windows/LoadingWindow.xaml.cs
index 0891dcc0..a7bbe923 100644
--- a/.Source/GTweak/Windows/LoadingWindow.xaml.cs
+++ b/.Source/GTweak/Windows/LoadingWindow.xaml.cs
@@ -52,23 +52,19 @@ namespace GTweak.Windows
catch (Exception ex) { ErrorLogging.LogWritingFile(ex, member); }
}
- Parallel.Invoke(
- () => ExecuteWithLogging(TrustedInstaller.StartTrustedInstallerService, nameof(TrustedInstaller.StartTrustedInstallerService)),
- () => ExecuteWithLogging(WindowsLicense.LicenseStatus, nameof(WindowsLicense.LicenseStatus)),
- () => ExecuteWithLogging(_systemDiagnostics.GetHardwareData, nameof(_systemDiagnostics.GetHardwareData)),
- () => ExecuteWithLogging(_systemDiagnostics.ValidateVersionUpdates, nameof(_systemDiagnostics.ValidateVersionUpdates)),
- () => ExecuteWithLogging(_uninstallingPakages.GetInstalledPackages, nameof(_uninstallingPakages.GetInstalledPackages)),
- () => ExecuteWithLogging(UninstallingPakages.CheckingForLocalAccount, nameof(UninstallingPakages.CheckingForLocalAccount)),
- () => ExecuteWithLogging(SystemTweaks.ViewNetshState, nameof(SystemTweaks.ViewNetshState)),
- () => ExecuteWithLogging(SystemTweaks.ViewBluetoothStatus, nameof(SystemTweaks.ViewBluetoothStatus)),
- () => ExecuteWithLogging(SystemTweaks.ViewConfigTick, nameof(SystemTweaks.ViewConfigTick))
- );
-
- ExecuteWithLogging(() => HardwareData.RunningProcessesCount = _systemDiagnostics.GetProcessCount().Result, nameof(_systemDiagnostics.GetProcessCount));
- ExecuteWithLogging(() => HardwareData.RunningServicesCount = _systemDiagnostics.GetServicesCount().Result, nameof(_systemDiagnostics.GetServicesCount));
+ ExecuteWithLogging(TrustedInstaller.StartTrustedInstallerService, nameof(TrustedInstaller.StartTrustedInstallerService));
+ ExecuteWithLogging(WindowsLicense.LicenseStatus, nameof(WindowsLicense.LicenseStatus));
+ ExecuteWithLogging(() => _systemDiagnostics.GetHardwareData(), nameof(_systemDiagnostics.GetHardwareData));
+ ExecuteWithLogging(_systemDiagnostics.ValidateVersionUpdates, nameof(_systemDiagnostics.ValidateVersionUpdates));
+ ExecuteWithLogging(_uninstallingPakages.GetInstalledPackages, nameof(_uninstallingPakages.GetInstalledPackages));
+ ExecuteWithLogging(UninstallingPakages.CheckingForLocalAccount, nameof(UninstallingPakages.CheckingForLocalAccount));
+ ExecuteWithLogging(SystemTweaks.ViewNetshState, nameof(SystemTweaks.ViewNetshState));
+ ExecuteWithLogging(SystemTweaks.ViewBluetoothStatus, nameof(SystemTweaks.ViewBluetoothStatus));
+ ExecuteWithLogging(SystemTweaks.ViewConfigTick, nameof(SystemTweaks.ViewConfigTick));
+ ExecuteWithLogging(() => HardwareData.RunningProcessesCount = _systemDiagnostics.GetProcessCount().GetAwaiter().GetResult(), nameof(_systemDiagnostics.GetProcessCount));
+ ExecuteWithLogging(() => HardwareData.RunningServicesCount = _systemDiagnostics.GetServicesCount().GetAwaiter().GetResult(), nameof(_systemDiagnostics.GetServicesCount));
ExecuteWithLogging(() => _systemDiagnostics.GetTotalProcessorUsage().GetAwaiter().GetResult(), nameof(_systemDiagnostics.GetTotalProcessorUsage));
ExecuteWithLogging(() => _systemDiagnostics.GetPhysicalAvailableMemory().GetAwaiter().GetResult(), nameof(_systemDiagnostics.GetPhysicalAvailableMemory));
-
}
private void BackgroundWorker_ProgressChanged(object sender, ProgressChangedEventArgs e)