Portable Tool for an Ideal Windows Setup
C# activatorbloatware-removalcsharpdebloatdebloaterdisable-servicesmonitoring-systemportableprivacy-toolsregistry-tweakssystem-tuningsystem-utilitytelemetrytweakerwindows-10windows-11windows-debloatwindows-defenderwindows-optimizationwindows-tweaks
universal pathfinding for executable file & re
Greedeks0d6537c45aa8
diff --git a/.Source/GTweak/Core/ViewModel/DataSystemVM.cs b/.Source/GTweak/Core/ViewModel/DataSystemVM.csindex 097e574f..f1535162 100644--- a/.Source/GTweak/Core/ViewModel/DataSystemVM.cs+++ b/.Source/GTweak/Core/ViewModel/DataSystemVM.cs@@ -65,22 +65,31 @@ namespace GTweak.Core.ViewModelDisplayData = new ObservableCollection<DataSystemModel>{- 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.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 }+ CreateModelCollection("Windows", SystemDiagnostics.HardwareData.OperatingSystem),+ CreateModelCollection("Processes", new MonitoringSystem().GetNumberRunningProcesses),+ CreateModelCollection("Bios", SystemDiagnostics.HardwareData.Bios, "no_device_information_systemInformatin"),+ CreateModelCollection("Mode", SystemDiagnostics.HardwareData.BiosMode, "no_device_information_systemInformatin"),+ CreateModelCollection("Motherboard", SystemDiagnostics.HardwareData.Motherboard, "no_device_information_systemInformatin"),+ CreateModelCollection("Processor", SystemDiagnostics.HardwareData.Processor, "no_device_information_systemInformatin"),+ CreateModelCollection("Graphics", SystemDiagnostics.HardwareData.Graphics, "driver_not_installed_systemInformatin"),+ CreateModelCollection("Memory", SystemDiagnostics.HardwareData.Memory, "no_device_information_systemInformatin"),+ CreateModelCollection("Storage", SystemDiagnostics.HardwareData.Storage, "no_device_information_systemInformatin"),+ CreateModelCollection("Audio", SystemDiagnostics.HardwareData.AudioDevice, "driver_not_installed_systemInformatin"),+ CreateModelCollection("Network", SystemDiagnostics.HardwareData.NetworkAdapter, "driver_not_installed_systemInformatin"),+ CreateModelCollection("IpAddress", SystemDiagnostics.HardwareData.UserIPAddress)};SetBlurValue = (SystemDiagnostics.isIPAddressFormatValid && SettingsEngine.IsHiddenIpAddress) ? 20 : 0;SetVisibility = SystemDiagnostics.isIPAddressFormatValid ? Visibility.Visible : Visibility.Hidden;}++ private DataSystemModel CreateModelCollection(string name, object data, string fallbackResourceKey = null)+ {+ return new DataSystemModel+ {+ Name = name,+ Data = (string)(fallbackResourceKey == null ? data : (!string.IsNullOrEmpty(data as string) ? data : (string)Application.Current.Resources[fallbackResourceKey]))+ };+ }}}diff --git a/.Source/GTweak/Utilities/Configuration/SystemDiagnostics.cs b/.Source/GTweak/Utilities/Configuration/SystemDiagnostics.csindex 1dfab622..90089899 100644--- a/.Source/GTweak/Utilities/Configuration/SystemDiagnostics.cs+++ b/.Source/GTweak/Utilities/Configuration/SystemDiagnostics.cs@@ -46,8 +46,8 @@ namespace GTweak.Utilities.Configurationinternal 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 OperatingSystem { get; set; } = $"\n{Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "ProductName", string.Empty)?.ToString()}" ?? string.Empty;+ internal static string OSVersion { get; set; } = 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;@@ -152,7 +152,7 @@ namespace GTweak.Utilities.Configuration/// </summary>private void GetBiosInfo(){- string output = CommandExecutor.GetCommandOutput(PathLocator.Files.BcdEditExe).GetAwaiter().GetResult();+ string output = CommandExecutor.GetCommandOutput(PathLocator.Executable.BcdEdit).GetAwaiter().GetResult();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())diff --git a/.Source/GTweak/Utilities/Controls/PathLocator.cs b/.Source/GTweak/Utilities/Controls/PathLocator.csindex 5d5955a0..4c2f7562 100644--- a/.Source/GTweak/Utilities/Controls/PathLocator.cs+++ b/.Source/GTweak/Utilities/Controls/PathLocator.cs@@ -6,8 +6,6 @@ namespace GTweak.Utilities.Controls{internal class PathLocator{- private static string FindExecutablePath(string name) => Environment.GetEnvironmentVariable("PATH")?.Split(Path.PathSeparator).Select(dir => Path.Combine(dir, name)).FirstOrDefault(File.Exists);-internal static class Folders{internal static readonly string Workspace = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "GTweak");@@ -17,6 +15,31 @@ namespace GTweak.Utilities.Controlsinternal static readonly string DefenderBackup = Path.Combine(Environment.SystemDirectory, "Config", "WDBackup_GTweak");}+ internal static class Executable+ {+ private static string FindExecutablePath(string name)+ {+ string path = Environment.GetEnvironmentVariable("PATH")?.Split(Path.PathSeparator).Select(dir => Path.Combine(dir, name)).FirstOrDefault(File.Exists);++ if (!string.IsNullOrWhiteSpace(path))+ return path;++ path = new[] { Environment.SystemDirectory, Environment.GetFolderPath(Environment.SpecialFolder.Windows) }.Select(dir => Path.Combine(dir, name)).FirstOrDefault(File.Exists);++ return path;+ }++ internal static readonly string CommandShell = FindExecutablePath("cmd.exe");++ internal static readonly string PowerShell = FindExecutablePath("pwsh.exe") ?? FindExecutablePath("powershell.exe");++ internal static readonly string BcdEdit = FindExecutablePath("bcdedit.exe");++ internal static readonly string PowerCfg = FindExecutablePath("powercfg.exe");++ internal static readonly string Explorer = FindExecutablePath("explorer.exe");+ }+internal static class Files{internal static string Config = string.Empty;@@ -33,11 +56,7 @@ namespace GTweak.Utilities.Controlsinternal static readonly string BackupRightsAcl = Path.Combine(Folders.DefenderBackup, "BackupRights.acl");- internal static readonly string CommandShellExe = FindExecutablePath("cmd.exe");-- internal static readonly string PowerShellExe = FindExecutablePath("pwsh.exe") ?? FindExecutablePath("powershell.exe");-- internal static readonly string BcdEditExe = FindExecutablePath("bcdedit.exe");+ internal static readonly string WindowsOld = Path.Combine(Folders.SystemDrive, "Windows.old");}internal static class Registrydiff --git a/.Source/GTweak/Utilities/Helpers/CommandExecutor.cs b/.Source/GTweak/Utilities/Helpers/CommandExecutor.csindex 220b6baa..05d7befe 100644--- a/.Source/GTweak/Utilities/Helpers/CommandExecutor.cs+++ b/.Source/GTweak/Utilities/Helpers/CommandExecutor.cs@@ -15,7 +15,7 @@ namespace GTweak.Utilities.Helpers{ProcessStartInfo startInfo = new ProcessStartInfo{- FileName = isPowerShell ? PathLocator.Files.PowerShellExe : PathLocator.Files.CommandShellExe,+ FileName = isPowerShell ? PathLocator.Executable.PowerShell : PathLocator.Executable.CommandShell,Arguments = isPowerShell ? $"-NoLogo -NonInteractive -NoProfile -ExecutionPolicy Bypass -Command \"{command}\"" : command,WindowStyle = ProcessWindowStyle.Hidden,RedirectStandardOutput = true,@@ -43,7 +43,7 @@ namespace GTweak.Utilities.Helpers}internal static void RunCommandAsTrustedInstaller(string command, bool isPowerShell = false) =>- TrustedInstaller.CreateProcessAsTrustedInstaller(PID, isPowerShell ? $"{PathLocator.Files.PowerShellExe} -NoLogo -NonInteractive -NoProfile -ExecutionPolicy Bypass -Command \"{command.Replace("\"", "`\"")}\"" : $"{PathLocator.Files.CommandShellExe} {command}");+ TrustedInstaller.CreateProcessAsTrustedInstaller(PID, isPowerShell ? $"{PathLocator.Executable.PowerShell} -NoLogo -NonInteractive -NoProfile -ExecutionPolicy Bypass -Command \"{command.Replace("\"", "`\"")}\"" : $"{PathLocator.Executable.CommandShell} {command}");internal static async void RunCommand(string command, bool isPowerShell = false){@@ -51,7 +51,7 @@ namespace GTweak.Utilities.Helpers{Process.Start(new ProcessStartInfo(){- FileName = isPowerShell ? PathLocator.Files.PowerShellExe : PathLocator.Files.CommandShellExe,+ FileName = isPowerShell ? PathLocator.Executable.PowerShell : PathLocator.Executable.CommandShell,Arguments = isPowerShell ? $"-NoLogo -NonInteractive -NoProfile -ExecutionPolicy Bypass -Command \"{command}\"" : command,WindowStyle = ProcessWindowStyle.Hidden,UseShellExecute = true,@@ -65,7 +65,7 @@ namespace GTweak.Utilities.Helpers{ProcessStartInfo startInfo = new ProcessStartInfo{- FileName = isPowerShell ? PathLocator.Files.PowerShellExe : PathLocator.Files.CommandShellExe,+ FileName = isPowerShell ? PathLocator.Executable.PowerShell : PathLocator.Executable.CommandShell,Arguments = isPowerShell ? $"-NoLogo -NonInteractive -NoProfile -ExecutionPolicy Bypass -Command \"{command}\"" : command,WindowStyle = ProcessWindowStyle.Hidden,RedirectStandardOutput = true,diff --git a/.Source/GTweak/Utilities/Managers/ExplorerManager.cs b/.Source/GTweak/Utilities/Managers/ExplorerManager.csindex 9db26471..23ce603a 100644--- a/.Source/GTweak/Utilities/Managers/ExplorerManager.cs+++ b/.Source/GTweak/Utilities/Managers/ExplorerManager.cs@@ -37,7 +37,7 @@ namespace GTweak.Utilities.Managers{try{- if (string.Compare(process.MainModule?.FileName, $@"{Environment.GetEnvironmentVariable("WINDIR")}\{"explorer.exe"}", StringComparison.OrdinalIgnoreCase) == 0 && Process.GetProcessesByName("explorer").Length != 0)+ if (string.Compare(process.MainModule?.FileName, PathLocator.Executable.Explorer, StringComparison.OrdinalIgnoreCase) == 0 && Process.GetProcessesByName("explorer").Length != 0){process.Kill();action?.Invoke();@@ -49,7 +49,7 @@ namespace GTweak.Utilities.Managers{if (Process.GetProcessesByName("explorer").Length == 0){- launchExplorer.StartInfo.FileName = $@"{Environment.GetEnvironmentVariable("WINDIR")}\explorer.exe";+ launchExplorer.StartInfo.FileName = PathLocator.Executable.Explorer;launchExplorer.StartInfo.Arguments = "/factory,{EFD469A7-7E0A-4517-8B39-45873948DA31}";launchExplorer.StartInfo.UseShellExecute = true;launchExplorer.Start();diff --git a/.Source/GTweak/Utilities/Tweaks/ClearingMemory.cs b/.Source/GTweak/Utilities/Tweaks/ClearingMemory.csindex 842b03e0..24f76c9e 100644--- a/.Source/GTweak/Utilities/Tweaks/ClearingMemory.cs+++ b/.Source/GTweak/Utilities/Tweaks/ClearingMemory.cs@@ -50,7 +50,7 @@ namespace GTweak.Utilities.Tweaksinternal class ClearingMemory{- internal static bool IsWinOldExists => Directory.Exists(Path.Combine(PathLocator.Folders.SystemDrive, "Windows.old"));+ internal static bool IsWinOldExists => Directory.Exists(PathLocator.Files.WindowsOld);private const int SE_PRIVILEGE_ENABLED = 2;private const string SE_INCREASE_QUOTA_NAME = "SeIncreaseQuotaPrivilege";@@ -185,11 +185,11 @@ namespace GTweak.Utilities.Tweaksif (shouldRemoveWinOld){- string filePath = Path.Combine(PathLocator.Folders.SystemDrive, "Windows.old");- CommandExecutor.RunCommandAsTrustedInstaller($"/c takeown /f \"{filePath}\"");- CommandExecutor.RunCommandAsTrustedInstaller($"/c icacls \"{filePath}\" /inheritance:r /remove S-1-5-32-544 S-1-5-11 S-1-5-32-545 S-1-5-18");- CommandExecutor.RunCommandAsTrustedInstaller($"/c icacls \"{filePath}\" /grant {Environment.UserName}:F");- CommandExecutor.RunCommandAsTrustedInstaller($"/c rd /s /q \"{filePath}\"");+ string dir = PathLocator.Files.WindowsOld;+ CommandExecutor.RunCommandAsTrustedInstaller($"/c takeown /f \"{dir}\"");+ CommandExecutor.RunCommandAsTrustedInstaller($"/c icacls \"{dir}\" /inheritance:r /remove S-1-5-32-544 S-1-5-11 S-1-5-32-545 S-1-5-18");+ CommandExecutor.RunCommandAsTrustedInstaller($"/c icacls \"{dir}\" /grant {Environment.UserName}:F");+ CommandExecutor.RunCommandAsTrustedInstaller($"/c rd /s /q \"{dir}\"");}CommandExecutor.RunCommandAsTrustedInstaller(@$"/c rd /s /q {PathLocator.Folders.SystemDrive}Windows\Temp & " +diff --git a/.Source/GTweak/Utilities/Tweaks/DefenderManager/WindowsDefender.cs b/.Source/GTweak/Utilities/Tweaks/DefenderManager/WindowsDefender.csindex a1fd9d13..25317463 100644--- a/.Source/GTweak/Utilities/Tweaks/DefenderManager/WindowsDefender.cs+++ b/.Source/GTweak/Utilities/Tweaks/DefenderManager/WindowsDefender.cs@@ -439,9 +439,9 @@ namespace GTweak.Utilities.Tweaks.DefenderManager}}- private static void RunPowerShellCommand(string command) => RunProcess(PathLocator.Files.PowerShellExe, "-NoLogo -NonInteractive -NoProfile -ExecutionPolicy Bypass -EncodedCommand \"" + Convert.ToBase64String(Encoding.Unicode.GetBytes(command)) + "\"");+ private static void RunPowerShellCommand(string command) => RunProcess(PathLocator.Executable.PowerShell, "-NoLogo -NonInteractive -NoProfile -ExecutionPolicy Bypass -EncodedCommand \"" + Convert.ToBase64String(Encoding.Unicode.GetBytes(command)) + "\"");- private static void RunCmdCommand(string command) => RunProcess(PathLocator.Files.CommandShellExe, "/d /q /c " + command);+ private static void RunCmdCommand(string command) => RunProcess(PathLocator.Executable.CommandShell, "/d /q /c " + command);private static void RunProcess(string path, string arguments){diff --git a/.Source/GTweak/Utilities/Tweaks/SystemMaintenance.cs b/.Source/GTweak/Utilities/Tweaks/SystemMaintenance.csindex ee27f6d3..eb50cc47 100644--- a/.Source/GTweak/Utilities/Tweaks/SystemMaintenance.cs+++ b/.Source/GTweak/Utilities/Tweaks/SystemMaintenance.cs@@ -3,6 +3,7 @@ using GTweak.Utilities.Helpers;using GTweak.Utilities.Managers;using Microsoft.Win32;using System;+using System.IO;using System.Management;using System.Runtime.InteropServices;using System.Windows;@@ -17,7 +18,6 @@ namespace GTweak.Utilities.Tweaksprivate static extern int SRRemoveRestorePoint(int index);private static readonly ManagementClass _restorePoint = new ManagementClass(new ManagementScope(@"\\localhost\root\default"), new ManagementPath("SystemRestore"), new ObjectGetOptions());private static ManagementBaseObject _inParams, _outParams;- private static bool _isWorkingCreatePoint = false;internal static bool IsSystemRestoreDisabled => RegistryHelp.CheckValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SystemRestore", "RPSessionInterval", "0");@@ -58,11 +58,8 @@ namespace GTweak.Utilities.Tweaksinternal static void CreateRestorePoint(){- if (_isWorkingCreatePoint) return;-try{- _isWorkingCreatePoint = true;RegistryHelp.Write(Registry.LocalMachine, @"SOFTWARE\Microsoft\Windows NT\CurrentVersion\SystemRestore", "SystemRestorePointCreationFrequency", 0, RegistryValueKind.DWord);EnableRecovery();@@ -84,14 +81,9 @@ namespace GTweak.Utilities.Tweakselsenew NotificationManager(300).Show("", "warn", "error_point_notification");- _isWorkingCreatePoint = false;RegistryHelp.DeleteValue(Registry.LocalMachine, @"SOFTWARE\Microsoft\Windows NT\CurrentVersion\SystemRestore", "SystemRestorePointCreationFrequency");}- catch- {- _isWorkingCreatePoint = false;- new NotificationManager().Show("", "warn", "error_point_notification");- }+ catch { new NotificationManager().Show("", "warn", "error_point_notification"); }}internal static void StartRecovery()@@ -133,7 +125,7 @@ namespace GTweak.Utilities.Tweaks_inParams = _restorePoint.GetMethodParameters("Enable");_inParams["WaitTillEnabled"] = true;- _inParams["Drive"] = System.IO.Path.GetPathRoot(Environment.SystemDirectory);+ _inParams["Drive"] = Path.GetPathRoot(Environment.SystemDirectory);_restorePoint.InvokeMethod("Enable", _inParams, null);}}diff --git a/.Source/GTweak/Utilities/Tweaks/SystemTweaks.cs b/.Source/GTweak/Utilities/Tweaks/SystemTweaks.csindex 7bdbcf8a..a7a2179e 100644--- a/.Source/GTweak/Utilities/Tweaks/SystemTweaks.cs+++ b/.Source/GTweak/Utilities/Tweaks/SystemTweaks.cs@@ -179,8 +179,8 @@ namespace GTweak.Utilities.Tweaksinternal void ViewConfigTick(){- string output = CommandExecutor.GetCommandOutput(PathLocator.Files.BcdEditExe).GetAwaiter().GetResult();- _isTickState = !Regex.IsMatch(output,@"(?is)(?=.*\bdisabledynamictick\s+(yes|true))(?=.*\buseplatformclock\s+(no|false))", RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture | RegexOptions.CultureInvariant);+ 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);}[DllImport("user32.dll")]@@ -423,12 +423,12 @@ namespace GTweak.Utilities.Tweaksif (isDisabled){_isTickState = false;- CommandExecutor.RunCommand($@"{PathLocator.Files.BcdEditExe} /set disabledynamictick yes; {PathLocator.Files.BcdEditExe} /set useplatformclock false", true);+ CommandExecutor.RunCommand($@"{PathLocator.Executable.BcdEdit} /set disabledynamictick yes; {PathLocator.Executable.BcdEdit} /set useplatformclock false", true);}else{_isTickState = true;- CommandExecutor.RunCommand($@"{PathLocator.Files.BcdEditExe} /deletevalue disabledynamictick; {PathLocator.Files.BcdEditExe} /deletevalue useplatformclock", true);+ CommandExecutor.RunCommand($@"{PathLocator.Executable.BcdEdit} /deletevalue disabledynamictick; {PathLocator.Executable.BcdEdit} /deletevalue useplatformclock", true);}break;}@@ -441,7 +441,7 @@ namespace GTweak.Utilities.TweaksProcess _powercfg = new Process(){StartInfo = {- FileName = "powercfg",+ FileName = PathLocator.Executable.PowerCfg,CreateNoWindow = true,WindowStyle = ProcessWindowStyle.Hidden},diff --git a/.Source/GTweak/Utilities/Tweaks/UninstallingPakages.cs b/.Source/GTweak/Utilities/Tweaks/UninstallingPakages.csindex e2c60416..804c34f3 100644--- a/.Source/GTweak/Utilities/Tweaks/UninstallingPakages.cs+++ b/.Source/GTweak/Utilities/Tweaks/UninstallingPakages.cs@@ -13,9 +13,8 @@ namespace GTweak.Utilities.Tweaks{internal sealed class UninstallingPakages : TaskSchedulerManager{- internal static bool IsOneDriveInstalled => File.Exists(Environment.ExpandEnvironmentVariables(@"%userprofile%\AppData\Local\Microsoft\OneDrive\OneDrive.exe"));+ internal static bool IsOneDriveInstalled => File.Exists(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Microsoft", "OneDrive", "OneDrive.exe"));private static bool _isLocalAccount = false;- private static readonly string _pathPackage = Path.Combine(PathLocator.Folders.SystemDrive, "Program Files", "WindowsApps");internal void LoadInstalledPackages() => InstalledPackages = RegistryHelp.GetSubKeyNames<HashSet<string>>(Registry.CurrentUser, @"Software\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\Repository\Packages");internal static HashSet<string> InstalledPackages = new HashSet<string>();@@ -136,7 +135,7 @@ namespace GTweak.Utilities.Tweaksawait CommandExecutor.InvokeRunCommand(string.Join(" ; ", psCommands), true).ConfigureAwait(false);- CommandExecutor.RunCommandAsTrustedInstaller($@"/c for /d %i in ({string.Join(" ", packageNamesToRemove.Select(n => $@"""{_pathPackage}\*{n}*"""))}) do takeown /f ""%i"" /r /d Y & icacls ""%i"" /inheritance:r /remove S-1-5-32-544 S-1-5-11 S-1-5-32-545 S-1-5-18 & icacls ""%i"" /grant {Environment.UserName}:F & rd /s /q ""%i""");+ CommandExecutor.RunCommandAsTrustedInstaller($@"/c for /d %i in ({string.Join(" ", packageNamesToRemove.Select(n => $@"""{Path.Combine(PathLocator.Folders.SystemDrive, "Program Files", "WindowsApps")}\*{n}*"""))}) do takeown /f ""%i"" /r /d Y & icacls ""%i"" /inheritance:r /remove S-1-5-32-544 S-1-5-11 S-1-5-32-545 S-1-5-18 & icacls ""%i"" /grant {Environment.UserName}:F & rd /s /q ""%i""");}catch (Exception ex) { ErrorLogging.LogDebug(ex); }@@ -259,8 +258,7 @@ namespace GTweak.Utilities.Tweaksif (!shouldRemoveWebView && (folder == "EdgeWebView" || folder == "EdgeCore" || folder == "EdgeUpdate"))continue;- string path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86), "Microsoft", folder);- RemoveDirectory(path);+ RemoveDirectory(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86), "Microsoft", folder));}try