Skip to content

Portable Tool for an Ideal Windows Setup

simplification of object handling & re

Greedeksa951b330854f
diff --git a/.Source/GTweak/Core/ViewModel/DataSystemVM.cs b/.Source/GTweak/Core/ViewModel/DataSystemVM.cs
index 7045d0b2..5d0f2bb0 100644
--- a/.Source/GTweak/Core/ViewModel/DataSystemVM.cs
+++ b/.Source/GTweak/Core/ViewModel/DataSystemVM.cs
@@ -65,18 +65,18 @@ namespace GTweak.Core.ViewModel
DisplayData = new ObservableCollection<DataSystemModel>
{
- new DataSystemModel { Name = "Windows", Data = SystemDiagnostics.HardwareData["Windows"] },
+ new DataSystemModel { Name = "Windows", Data = SystemDiagnostics.HardwareData.OperatingSystem },
new DataSystemModel { Name = "Processes", Data = new MonitoringSystem().GetNumberRunningProcesses },
- new DataSystemModel { Name = "Bios", Data = !string.IsNullOrEmpty(SystemDiagnostics.HardwareData["BIOS"]) ? SystemDiagnostics.HardwareData["BIOS"] : (string)Application.Current.Resources["no_device_information_systemInformatin"] },
- new DataSystemModel { Name = "Mode", Data = !string.IsNullOrEmpty(SystemDiagnostics.HardwareData["Mode"]) ? SystemDiagnostics.HardwareData["Mode"] : (string)Application.Current.Resources["no_device_information_systemInformatin"] },
- new DataSystemModel { Name = "Motherboard", Data = !string.IsNullOrEmpty(SystemDiagnostics.HardwareData["MotherBr"]) ? SystemDiagnostics.HardwareData["MotherBr"] : (string)Application.Current.Resources["no_device_information_systemInformatin"] },
- new DataSystemModel { Name = "Processor", Data = !string.IsNullOrEmpty(SystemDiagnostics.HardwareData["CPU"]) ? SystemDiagnostics.HardwareData["CPU"] : (string)Application.Current.Resources["no_device_information_systemInformatin"] },
- new DataSystemModel { Name = "Graphics", Data = !string.IsNullOrEmpty(SystemDiagnostics.HardwareData["GPU"]) ? SystemDiagnostics.HardwareData["GPU"] : (string)Application.Current.Resources["driver_not_installed_systemInformatin"] },
- new DataSystemModel { Name = "Memory", Data = !string.IsNullOrEmpty(SystemDiagnostics.HardwareData["RAM"]) ? SystemDiagnostics.HardwareData["RAM"] : (string)Application.Current.Resources["no_device_information_systemInformatin"] },
- new DataSystemModel { Name = "Storage", Data = !string.IsNullOrEmpty(SystemDiagnostics.HardwareData["Storage"]) ? SystemDiagnostics.HardwareData["Storage"] : (string)Application.Current.Resources["no_device_information_systemInformatin"] },
- new DataSystemModel { Name = "Audio", Data = !string.IsNullOrEmpty(SystemDiagnostics.HardwareData["Audio"]) ? SystemDiagnostics.HardwareData["Audio"] : (string)Application.Current.Resources["driver_not_installed_systemInformatin"] },
- new DataSystemModel { Name = "Network", Data = !string.IsNullOrEmpty(SystemDiagnostics.HardwareData["NetAdapter"]) ? SystemDiagnostics.HardwareData["NetAdapter"] : (string)Application.Current.Resources["driver_not_installed_systemInformatin"] },
- new DataSystemModel { Name = "IpAddress", Data = SystemDiagnostics.HardwareData["UserIpAddress"] }
+ new DataSystemModel { Name = "Bios", Data = !string.IsNullOrEmpty(SystemDiagnostics.HardwareData.Bios) ? SystemDiagnostics.HardwareData.Bios : (string)Application.Current.Resources["no_device_information_systemInformatin"] },
+ new DataSystemModel { Name = "Mode", Data = !string.IsNullOrEmpty(SystemDiagnostics.HardwareData.BiosMode) ? SystemDiagnostics.HardwareData.BiosMode : (string)Application.Current.Resources["no_device_information_systemInformatin"] },
+ new DataSystemModel { Name = "Motherboard", Data = !string.IsNullOrEmpty(SystemDiagnostics.HardwareData.Motherboard) ? SystemDiagnostics.HardwareData.Motherboard : (string)Application.Current.Resources["no_device_information_systemInformatin"] },
+ new DataSystemModel { Name = "Processor", Data = !string.IsNullOrEmpty(SystemDiagnostics.HardwareData.Processor) ? SystemDiagnostics.HardwareData.Processor : (string)Application.Current.Resources["no_device_information_systemInformatin"] },
+ new DataSystemModel { Name = "Graphics", Data = !string.IsNullOrEmpty(SystemDiagnostics.HardwareData.Graphics) ? SystemDiagnostics.HardwareData.Graphics : (string)Application.Current.Resources["driver_not_installed_systemInformatin"] },
+ new DataSystemModel { Name = "Memory", Data = !string.IsNullOrEmpty(SystemDiagnostics.HardwareData.Memory) ? SystemDiagnostics.HardwareData.Memory : (string)Application.Current.Resources["no_device_information_systemInformatin"] },
+ new DataSystemModel { Name = "Storage", Data = !string.IsNullOrEmpty(SystemDiagnostics.HardwareData.Storage) ? SystemDiagnostics.HardwareData.Storage : (string)Application.Current.Resources["no_device_information_systemInformatin"] },
+ new DataSystemModel { Name = "Audio", Data = !string.IsNullOrEmpty(SystemDiagnostics.HardwareData.AudioDevice) ? SystemDiagnostics.HardwareData.AudioDevice : (string)Application.Current.Resources["driver_not_installed_systemInformatin"] },
+ new DataSystemModel { Name = "Network", Data = !string.IsNullOrEmpty(SystemDiagnostics.HardwareData.NetworkAdapter) ? SystemDiagnostics.HardwareData.NetworkAdapter : (string)Application.Current.Resources["driver_not_installed_systemInformatin"] },
+ new DataSystemModel { Name = "IpAddress", Data = SystemDiagnostics.HardwareData.UserIPAddress }
};
SetBlurValue = (SystemDiagnostics.isIPAddressFormatValid && SettingsRepository.IsHiddenIpAddress) ? 20 : 0;
diff --git a/.Source/GTweak/Utilities/Configuration/SystemDiagnostics.cs b/.Source/GTweak/Utilities/Configuration/SystemDiagnostics.cs
index 51d7b106..e82c5875 100644
--- a/.Source/GTweak/Utilities/Configuration/SystemDiagnostics.cs
+++ b/.Source/GTweak/Utilities/Configuration/SystemDiagnostics.cs
@@ -37,6 +37,23 @@ namespace GTweak.Utilities.Configuration
internal string Country { get; set; }
}
+ internal struct HardwareData
+ {
+ internal static string OperatingSystem { get; set; } = string.Empty;
+ internal static string OSVersion { get; set; } = Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "ProductName", string.Empty)?.ToString() ?? string.Empty;
+ internal static string OSBuild { get; set; } = string.Empty;
+ internal static string Bios { get; set; } = string.Empty;
+ internal static string BiosMode { get; set; } = string.Empty;
+ internal static string Motherboard { get; set; } = string.Empty;
+ internal static string Processor { get; set; } = string.Empty;
+ internal static string Graphics { get; set; } = string.Empty;
+ internal static string Memory { get; set; } = string.Empty;
+ internal static string Storage { get; set; } = string.Empty;
+ internal static string AudioDevice { get; set; } = string.Empty;
+ internal static string NetworkAdapter { get; set; } = string.Empty;
+ internal static string UserIPAddress { get; set; } = Application.Current.Resources["connection_lose_systemInformation"].ToString();
+ }
+
internal enum ConnectionStatus
{
Available,
@@ -49,29 +66,10 @@ namespace GTweak.Utilities.Configuration
internal static bool IsNeedUpdate { get; private set; } = false;
internal static string DownloadVersion { get; private set; } = string.Empty;
- internal static string WindowsClientVersion { get; set; } = Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "ProductName", string.Empty)?.ToString() ?? string.Empty;
- internal static string WindowsBuildVersion { get; set; } = string.Empty;
internal static Dictionary<byte, bool> IsWindowsVersion = default;
- private static (string Storage, string Audio, string NetAdapter) _tempData = (Storage: string.Empty, Audio: string.Empty, NetAdapter: string.Empty);
-
- internal static Dictionary<string, string> HardwareData = new Dictionary<string, string>()
- {
- { "Windows", WindowsClientVersion },
-
- { "BIOS", string.Empty },
- { "Mode", string.Empty },
- { "MotherBr", string.Empty },
- { "CPU", string.Empty },
- { "GPU", string.Empty },
- { "RAM", string.Empty },
- { "Storage", string.Empty },
- { "Audio", string.Empty },
- { "NetAdapter", string.Empty },
-
- { "UserIpAddress", Application.Current.Resources["connection_lose_systemInformation"].ToString() }
- };
+ private static (string Storage, string Audio, string NetAdapter) _tempData = (string.Empty, string.Empty, string.Empty);
internal static bool isIPAddressFormatValid = false;
@@ -114,31 +112,33 @@ namespace GTweak.Utilities.Configuration
internal void UpdatingDevicesData()
{
+ _tempData = (string.Empty, string.Empty, string.Empty);
+
Parallel.Invoke(
GetStorageDevices,
GetAudioDevices,
GetNetworkAdapters
);
- HardwareData["Storage"] = _tempData.Storage;
- HardwareData["Audio"] = _tempData.Audio;
- HardwareData["NetAdapter"] = _tempData.NetAdapter;
+ HardwareData.Storage = _tempData.Storage;
+ HardwareData.AudioDevice = _tempData.Audio;
+ HardwareData.NetworkAdapter = _tempData.NetAdapter;
}
internal void GetOperatingSystemInfo()
{
foreach (var managementObj in new ManagementObjectSearcher(@"root\cimv2", "select Caption, OSArchitecture, BuildNumber, Version from Win32_OperatingSystem", new EnumerationOptions { ReturnImmediately = true }).Get())
{
- WindowsClientVersion = Convert.ToString(managementObj["Caption"]);
- WindowsBuildVersion = Convert.ToString(managementObj["BuildNumber"]);
- HardwareData["Windows"] = $"{WindowsClientVersion.Substring(WindowsClientVersion.IndexOf('W'))}, {Regex.Replace((string)managementObj["OSArchitecture"], @"\-.+", "-bit")}, V{(string)managementObj["Version"]}\n";
+ HardwareData.OSVersion = Convert.ToString(managementObj["Caption"]);
+ HardwareData.OSBuild = Convert.ToString(managementObj["BuildNumber"]);
+ HardwareData.OperatingSystem = $"{HardwareData.OSVersion.Substring(HardwareData.OSVersion.IndexOf('W'))}, {Regex.Replace((string)managementObj["OSArchitecture"], @"\-.+", "-bit")}, V{(string)managementObj["Version"]}\n";
IsWindowsVersion = new Dictionary<byte, bool>()
{
- { 11, WindowsClientVersion.Contains("11") },
- { 10, WindowsClientVersion.Contains("10") }
+ { 11, HardwareData.OSVersion.Contains("11") },
+ { 10, HardwareData.OSVersion.Contains("10") }
};
}
- HardwareData["Windows"] = $"\n{HardwareData["Windows"].TrimEnd('\n')}";
+ HardwareData.OperatingSystem = $"\n{HardwareData.OperatingSystem.TrimEnd('\n')}";
}
/// <summary>
@@ -148,15 +148,15 @@ namespace GTweak.Utilities.Configuration
private async void GetBiosInfo()
{
string output = await CommandExecutor.GetCommandOutput("bcdedit");
- HardwareData["Mode"] = output.IndexOf("efi", StringComparison.OrdinalIgnoreCase) >= 0 ? "UEFI" : "Legacy Boot";
+ HardwareData.BiosMode = output.IndexOf("efi", StringComparison.OrdinalIgnoreCase) >= 0 ? "UEFI" : "Legacy Boot";
foreach (var managementObj in new ManagementObjectSearcher(@"root\cimv2", "select Name, Caption, Description, SMBIOSBIOSVersion, SerialNumber from Win32_BIOS", new EnumerationOptions { ReturnImmediately = true }).Get())
{
string data = new[] { "Name", "Caption", "Description", "SMBIOSBIOSVersion" }.Select(prop => managementObj[prop] as string).FirstOrDefault(info => !string.IsNullOrEmpty(info)) ?? string.Empty;
string dataSN = (string)managementObj["SerialNumber"];
- HardwareData["BIOS"] += !string.IsNullOrWhiteSpace(dataSN) && !dataSN.Any(char.IsWhiteSpace) ? $"{data}, S/N-{dataSN}\n" : $"{data}\n";
+ HardwareData.Bios += !string.IsNullOrWhiteSpace(dataSN) && !dataSN.Any(char.IsWhiteSpace) ? $"{data}, S/N-{dataSN}\n" : $"{data}\n";
}
- HardwareData["BIOS"] = HardwareData["BIOS"].TrimEnd('\n');
+ HardwareData.Bios = HardwareData.Bios.TrimEnd('\n');
}
private void GetMotherboardInfo()
@@ -165,16 +165,16 @@ namespace GTweak.Utilities.Configuration
{
string data = $"{(string)managementObj["Manufacturer"]}{(string)managementObj["Product"]}";
string dataVersion = (string)managementObj["Version"];
- HardwareData["MotherBr"] += !string.IsNullOrWhiteSpace(dataVersion) && !dataVersion.Any(char.IsWhiteSpace) ? $"{data}, V{dataVersion}\n" : $"{data}\n";
+ HardwareData.Motherboard += !string.IsNullOrWhiteSpace(dataVersion) && !dataVersion.Any(char.IsWhiteSpace) ? $"{data}, V{dataVersion}\n" : $"{data}\n";
}
- HardwareData["MotherBr"] = HardwareData["MotherBr"].TrimEnd('\n');
+ HardwareData.Motherboard = HardwareData.Motherboard.TrimEnd('\n');
}
private void GetProcessorInfo()
{
foreach (var managementObj in new ManagementObjectSearcher(@"root\cimv2", "select Name from Win32_Processor", new EnumerationOptions { ReturnImmediately = true }).Get())
- HardwareData["CPU"] = $"{(string)managementObj["Name"]}\n";
- HardwareData["CPU"] = HardwareData["CPU"].TrimEnd('\n');
+ HardwareData.Processor = $"{(string)managementObj["Name"]}\n";
+ HardwareData.Processor = HardwareData.Processor.TrimEnd('\n');
}
/// <summary>
@@ -239,9 +239,9 @@ namespace GTweak.Utilities.Configuration
{
string data = managementObj["Name"] as string;
(bool isFound, string dataMemoryReg, string driverDesc) = GetMemorySize(data);
- HardwareData["GPU"] += $"{(data == null && !string.IsNullOrEmpty(driverDesc) ? driverDesc : data)}, {(isFound ? dataMemoryReg : SizeCalculationHelper((uint)managementObj["AdapterRAM"]))}\n";
+ HardwareData.Graphics += $"{(data == null && !string.IsNullOrEmpty(driverDesc) ? driverDesc : data)}, {(isFound ? dataMemoryReg : SizeCalculationHelper((uint)managementObj["AdapterRAM"]))}\n";
}
- HardwareData["GPU"] = HardwareData["GPU"].TrimEnd('\n');
+ HardwareData.Graphics = HardwareData.Graphics.TrimEnd('\n');
}
/// <summary>
@@ -264,9 +264,9 @@ namespace GTweak.Utilities.Configuration
35 => "LPDDR5",
_ => string.Empty
};
- HardwareData["RAM"] += $"{(manufacturer.Equals("Unknown", StringComparison.OrdinalIgnoreCase) || string.IsNullOrEmpty(manufacturer) ? string.Concat(memoryType, ", ") : string.Concat(manufacturer, ", "))}{SizeCalculationHelper((ulong)managementObj["Capacity"])}{(string.IsNullOrEmpty(speedData) ? "" : $", {speedData}MHz")}\n";
+ HardwareData.Memory += $"{(manufacturer.Equals("Unknown", StringComparison.OrdinalIgnoreCase) || string.IsNullOrEmpty(manufacturer) ? string.Concat(memoryType, ", ") : string.Concat(manufacturer, ", "))}{SizeCalculationHelper((ulong)managementObj["Capacity"])}{(string.IsNullOrEmpty(speedData) ? "" : $", {speedData}MHz")}\n";
}
- HardwareData["RAM"] = HardwareData["RAM"].TrimEnd('\n');
+ HardwareData.Memory = HardwareData.Memory.TrimEnd('\n');
}
/// <summary>
@@ -274,7 +274,6 @@ namespace GTweak.Utilities.Configuration
/// </summary>
private static void GetStorageDevices()
{
- _tempData.Storage = string.Empty;
bool isMsftWorking = false;
try
@@ -366,7 +365,6 @@ namespace GTweak.Utilities.Configuration
return (false, string.Empty);
}
- _tempData.Audio = string.Empty;
using (ManagementObjectSearcher searcher = new ManagementObjectSearcher(@"root\cimv2", "select DeviceID, Name, Caption, Description from Win32_SoundDevice where Status = 'OK'", new EnumerationOptions { ReturnImmediately = true }))
{
foreach (ManagementObject managementObj in searcher.Get().Cast<ManagementObject>())
@@ -396,7 +394,6 @@ namespace GTweak.Utilities.Configuration
private void GetNetworkAdapters()
{
- _tempData.NetAdapter = string.Empty;
foreach (var managementObj in new ManagementObjectSearcher(@"root\cimv2", "select Name, Description, ProductName, Manufacturer from Win32_NetworkAdapter where NetConnectionStatus=2 or NetConnectionStatus=7", new EnumerationOptions { ReturnImmediately = true }).Get())
_tempData.NetAdapter += $"{new[] { "Name", "Description", "ProductName", "Manufacturer" }.Select(prop => managementObj[prop] as string).FirstOrDefault(info => !string.IsNullOrEmpty(info))}\n" ?? string.Empty;
_tempData.NetAdapter = _tempData.NetAdapter.TrimEnd('\n');
@@ -459,7 +456,7 @@ namespace GTweak.Utilities.Configuration
if (IPAddress.TryParse(ipMetadata.Ip, out _) && !string.IsNullOrEmpty(ipMetadata?.Ip) && !string.IsNullOrEmpty(ipMetadata?.Country))
{
CurrentConnection = ConnectionStatus.Available;
- HardwareData["UserIpAddress"] = $"{ipMetadata.Ip} ({ipMetadata.Country})";
+ HardwareData.UserIPAddress = $"{ipMetadata.Ip} ({ipMetadata.Country})";
}
else
CurrentConnection = ConnectionStatus.Block;
@@ -474,9 +471,9 @@ namespace GTweak.Utilities.Configuration
{ ConnectionStatus.Lose, "connection_lose_systemInformation" },
{ ConnectionStatus.Block, "connection_block_systemInformation" },
{ ConnectionStatus.Limited, "limited_systemInformation" }
- }.TryGetValue(CurrentConnection, out string resourceKey)) { HardwareData["UserIpAddress"] = (string)Application.Current.Resources[resourceKey]; }
+ }.TryGetValue(CurrentConnection, out string resourceKey)) { HardwareData.UserIPAddress = (string)Application.Current.Resources[resourceKey]; }
- isIPAddressFormatValid = HardwareData["UserIpAddress"].Any(char.IsDigit);
+ isIPAddressFormatValid = HardwareData.UserIPAddress.Any(char.IsDigit);
});
}
diff --git a/.Source/GTweak/Utilities/Controls/BlockRunTweaker.cs b/.Source/GTweak/Utilities/Controls/BlockRunTweaker.cs
index a21ab8e8..609545cc 100644
--- a/.Source/GTweak/Utilities/Controls/BlockRunTweaker.cs
+++ b/.Source/GTweak/Utilities/Controls/BlockRunTweaker.cs
@@ -46,7 +46,7 @@ namespace GTweak.Utilities.Controls
{
Task.Run(delegate { new SystemDiagnostics().GetOperatingSystemInfo(); }).Wait();
- if ((SystemDiagnostics.IsWindowsVersion[11] || SystemDiagnostics.IsWindowsVersion[10]) && SystemDiagnostics.WindowsBuildVersion.CompareTo("18362.116") >= 0) return;
+ if ((SystemDiagnostics.IsWindowsVersion[11] || SystemDiagnostics.IsWindowsVersion[10]) && SystemDiagnostics.HardwareData.OSBuild.CompareTo("18362.116") >= 0) return;
new MessageWindow(true).ShowDialog();
}
}
diff --git a/.Source/GTweak/Utilities/Controls/SettingsRepository.cs b/.Source/GTweak/Utilities/Controls/SettingsRepository.cs
index e5e798dd..3d9556f3 100644
--- a/.Source/GTweak/Utilities/Controls/SettingsRepository.cs
+++ b/.Source/GTweak/Utilities/Controls/SettingsRepository.cs
@@ -11,7 +11,6 @@ using System.Runtime.InteropServices;
namespace GTweak.Utilities.Controls
{
- [StructLayout(LayoutKind.Sequential)]
internal struct StoragePaths
{
internal static string Config = string.Empty;
diff --git a/.Source/GTweak/Utilities/Tweaks/ConfidentialityTweaks.cs b/.Source/GTweak/Utilities/Tweaks/ConfidentialityTweaks.cs
index 5fc76af6..5685cefe 100644
--- a/.Source/GTweak/Utilities/Tweaks/ConfidentialityTweaks.cs
+++ b/.Source/GTweak/Utilities/Tweaks/ConfidentialityTweaks.cs
@@ -80,7 +80,7 @@ namespace GTweak.Utilities.Tweaks
confidentialityV.TglButton16.StateNA =
RegistryHelp.CheckValue(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\diagnosticshub.standardcollector.service", "Start", "4");
- confidentialityV.TglButton17.StateNA = SystemDiagnostics.HardwareData["GPU"].ToLower().Contains("nvidia")
+ confidentialityV.TglButton17.StateNA = SystemDiagnostics.HardwareData.Graphics.ToLower().Contains("nvidia")
&& (RegistryHelp.CheckValue(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\NvTelemetryContainer", "Start", "4") || IsTaskEnabled(nvidiaTasks));
confidentialityV.TglButton18.StateNA =
diff --git a/.Source/GTweak/Utilities/Tweaks/InterfaceTweaks.cs b/.Source/GTweak/Utilities/Tweaks/InterfaceTweaks.cs
index 6be7925c..cca44fc9 100644
--- a/.Source/GTweak/Utilities/Tweaks/InterfaceTweaks.cs
+++ b/.Source/GTweak/Utilities/Tweaks/InterfaceTweaks.cs
@@ -301,7 +301,7 @@ namespace GTweak.Utilities.Tweaks
RegistryHelp.Write(Registry.CurrentUser, @"Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "TaskbarMn", isChoose ? 0 : 1, RegistryValueKind.DWord);
RegistryHelp.Write(Registry.CurrentUser, @"Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "EnableSnapAssistFlyout", isChoose ? 0 : 1, RegistryValueKind.DWord);
- if (isChoose && SystemDiagnostics.WindowsBuildVersion.CompareTo("22635.3785") >= 0)
+ if (isChoose && SystemDiagnostics.HardwareData.OSBuild.CompareTo("22635.3785") >= 0)
{
RegistryHelp.DeleteFolderTree(Registry.CurrentUser, @"Software\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace\{2cc5ca98-6485-489a-920e-b3e88a6ccce3}");
RegistryHelp.Write(Registry.CurrentUser, @"Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel", "{2cc5ca98-6485-489a-920e-b3e88a6ccce3}", 1, RegistryValueKind.DWord);
diff --git a/.Source/GTweak/Utilities/Tweaks/ServicesTweaks.cs b/.Source/GTweak/Utilities/Tweaks/ServicesTweaks.cs
index ced946b8..f01bff9a 100644
--- a/.Source/GTweak/Utilities/Tweaks/ServicesTweaks.cs
+++ b/.Source/GTweak/Utilities/Tweaks/ServicesTweaks.cs
@@ -5,7 +5,6 @@ using GTweak.View;
using Microsoft.Win32;
using System;
using System.Collections.Generic;
-using System.ComponentModel;
using System.IO;
using System.Linq;
using System.ServiceProcess;
@@ -321,20 +320,8 @@ namespace GTweak.Utilities.Tweaks
break;
case "TglButton15":
BlockWindowsUpdate(isChoose);
- ChangeAccessUpdateFolders(isChoose);
-
- using (BackgroundWorker backgroundWorker = new BackgroundWorker())
- {
- backgroundWorker.DoWork += delegate
- {
- string argurment = default;
- foreach (var key in _updateFilesWin)
- argurment += isChoose ? $"rename {FilesPathUpdate(key.Value.Default)} {key.Value.Blocked} & " : $"rename {FilesPathUpdate(key.Value.Blocked)} {key.Value.Default} & ";
-
- TrustedInstaller.CreateProcessAsTrustedInstaller(SettingsRepository.PID, $"cmd.exe /c {argurment.Substring(0, argurment.Length - 3)}");
- };
- backgroundWorker.RunWorkerAsync();
- }
+ string[] arguments = _updateFilesWin.Select(key => isChoose ? $"rename \"{FilesPathUpdate(key.Value.Default)}\" \"{key.Value.Blocked}\"" : $"rename \"{FilesPathUpdate(key.Value.Blocked)}\" \"{key.Value.Default}\"").ToArray();
+ TrustedInstaller.CreateProcessAsTrustedInstaller(SettingsRepository.PID, $"cmd.exe /c {string.Join(" & ", arguments)}");
RegistryHelp.Write(Registry.LocalMachine, @"SYSTEM\CurrentControlSet\Services\wisvc", "Start", isChoose ? 4 : 3, RegistryValueKind.DWord);
RegistryHelp.Write(Registry.LocalMachine, @"SYSTEM\CurrentControlSet\Services\DmEnrollmentSvc", "Start", isChoose ? 4 : 3, RegistryValueKind.DWord);
@@ -355,6 +342,7 @@ namespace GTweak.Utilities.Tweaks
}
else
RegistryHelp.DeleteFolderTree(Registry.LocalMachine, @"SOFTWARE\Microsoft\Windows\WindowsUpdate");
+ ChangeAccessUpdateFolders(isChoose);
break;
case "TglButton16":
RegistryHelp.Write(Registry.LocalMachine, @"SYSTEM\CurrentControlSet\Services\PolicyAgent", "Start", isChoose ? 4 : 3, RegistryValueKind.DWord);
diff --git a/.Source/GTweak/Utilities/Tweaks/WindowsLicense.cs b/.Source/GTweak/Utilities/Tweaks/WindowsLicense.cs
index f5402bc2..17ff2993 100644
--- a/.Source/GTweak/Utilities/Tweaks/WindowsLicense.cs
+++ b/.Source/GTweak/Utilities/Tweaks/WindowsLicense.cs
@@ -20,7 +20,7 @@ namespace GTweak.Utilities.Tweaks
{
internal static bool IsWindowsActivated = false;
- private static bool IsVersionWindows(string pattern, byte words) => new Regex(pattern, RegexOptions.IgnoreCase | RegexOptions.CultureInvariant | RegexOptions.IgnorePatternWhitespace | RegexOptions.Compiled).Matches(SystemDiagnostics.WindowsClientVersion).Count == words;
+ private static bool IsVersionWindows(string pattern, byte words) => new Regex(pattern, RegexOptions.IgnoreCase | RegexOptions.CultureInvariant | RegexOptions.IgnorePatternWhitespace | RegexOptions.Compiled).Matches(SystemDiagnostics.HardwareData.OSVersion).Count == words;
internal void LicenseStatus()
{
diff --git a/.Source/GTweak/View/DataSystemView.xaml.cs b/.Source/GTweak/View/DataSystemView.xaml.cs
index f295ef94..4f1db654 100644
--- a/.Source/GTweak/View/DataSystemView.xaml.cs
+++ b/.Source/GTweak/View/DataSystemView.xaml.cs
@@ -32,7 +32,7 @@ namespace GTweak.View
{ SystemDiagnostics.ConnectionStatus.Lose, "connection_lose_systemInformation" },
{ SystemDiagnostics.ConnectionStatus.Block, "connection_block_systemInformation" },
{ SystemDiagnostics.ConnectionStatus.Limited, "limited_systemInformation" }
- }.TryGetValue(SystemDiagnostics.CurrentConnection, out string resourceKey)) { SystemDiagnostics.HardwareData["UserIpAddress"] = (string)FindResource(resourceKey); }
+ }.TryGetValue(SystemDiagnostics.CurrentConnection, out string resourceKey)) { SystemDiagnostics.HardwareData.UserIPAddress = (string)FindResource(resourceKey); }
DataContext = new DataSystemVM();
};
diff --git a/.Source/GTweak/View/InterfaceView.xaml.cs b/.Source/GTweak/View/InterfaceView.xaml.cs
index 48b7685b..361a2dc6 100644
--- a/.Source/GTweak/View/InterfaceView.xaml.cs
+++ b/.Source/GTweak/View/InterfaceView.xaml.cs
@@ -24,7 +24,7 @@ namespace GTweak.View
if (!WindowsLicense.IsWindowsActivated)
new ViewNotification().Show("", "info", "viewlicense_notification");
- if (SystemDiagnostics.WindowsBuildVersion.CompareTo("22621.2361") < 0)
+ if (SystemDiagnostics.HardwareData.OSBuild.CompareTo("22621.2361") < 0)
TglButton21.IsEnabled = false;
}