Portable Tool for an Ideal Windows Setup
C# activatorbloatware-removalcsharpdebloatdebloaterdisable-servicesmonitoring-systemportableprivacy-toolsregistry-tweakssystem-tuningsystem-utilitytelemetrytweakerwindows-10windows-11windows-debloatwindows-defenderwindows-optimizationwindows-tweaks
correcting conflict of rights when rd folders
Greedeksd2178f7d2262
diff --git a/.Source/GTweak/Utilities/Tweaks/ClearingMemory.cs b/.Source/GTweak/Utilities/Tweaks/ClearingMemory.csindex 66fe2fbb..14bcf660 100644--- a/.Source/GTweak/Utilities/Tweaks/ClearingMemory.cs+++ b/.Source/GTweak/Utilities/Tweaks/ClearingMemory.cs@@ -8,6 +8,7 @@ using System.Diagnostics;using System.IO;using System.Runtime.InteropServices;using System.Security.Principal;+using System.Threading;using System.Threading.Tasks;namespace GTweak.Utilities.Tweaks@@ -178,7 +179,7 @@ namespace GTweak.Utilities.Tweaksreturn num != 0;}- internal static void StartMemoryCleanupAsync(bool shouldRemoveWinOld = false)+ internal static void StartMemoryCleanup(bool shouldRemoveWinOld = false){ClearFileSystemCache(true);EmptyWorkingSetFunction();@@ -190,6 +191,15 @@ namespace GTweak.Utilities.TweaksCommandExecutor.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}\"");++ Thread.Sleep(2000);++ if (Directory.Exists(dir))+ {+ try { Directory.Delete(dir, true); } catch (Exception ex) { ErrorLogging.LogDebug(ex); }+ TakingOwnership.GrantAdministratorsAccess(dir, TakingOwnership.SE_OBJECT_TYPE.SE_FILE_OBJECT);+ 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/ServicesTweaks.cs b/.Source/GTweak/Utilities/Tweaks/ServicesTweaks.csindex 5591451c..98c20415 100644--- a/.Source/GTweak/Utilities/Tweaks/ServicesTweaks.cs+++ b/.Source/GTweak/Utilities/Tweaks/ServicesTweaks.cs@@ -447,10 +447,11 @@ namespace GTweak.Utilities.TweaksCommandExecutor.RunCommandAsTrustedInstaller($"/c icacls \"{path}\" /grant {Environment.UserName}:F");CommandExecutor.RunCommandAsTrustedInstaller($"/c rd /s /q \"{path}\"");- Thread.Sleep(1000);+ Thread.Sleep(2000);if (Directory.Exists(path)){+ try { Directory.Delete(path, true); } catch (Exception ex) { ErrorLogging.LogDebug(ex); }TakingOwnership.GrantAdministratorsAccess(path, TakingOwnership.SE_OBJECT_TYPE.SE_FILE_OBJECT);CommandExecutor.RunCommandAsTrustedInstaller($"/c rd /s /q \"{path}\"");}diff --git a/.Source/GTweak/Utilities/Tweaks/UninstallingPakages.cs b/.Source/GTweak/Utilities/Tweaks/UninstallingPakages.csindex d77f3603..062690e9 100644--- a/.Source/GTweak/Utilities/Tweaks/UninstallingPakages.cs+++ b/.Source/GTweak/Utilities/Tweaks/UninstallingPakages.cs@@ -211,7 +211,7 @@ namespace GTweak.Utilities.Tweaksforeach (string processName in new string[] { "msedge", "pwahelper", "edgeupdate", "edgeupdatem", "msedgewebview2", "MicrosoftEdgeUpdate", "msedgewebviewhost", "msedgeuserbroker", "usocoreworker", "RuntimeBroker" }){foreach (Process process in Process.GetProcessesByName(processName))- CommandExecutor.RunCommandAsTrustedInstaller($"{PathLocator.Executable.NSudo} -U:T -P:E -ShowWindowMode:Hide -Wait cmd /c taskkill /pid {process.Id} /f");+ CommandExecutor.RunCommandAsTrustedInstaller($"/c taskkill /pid {process.Id} /f");}RemoveTasks(edgeTasks);@@ -254,12 +254,14 @@ namespace GTweak.Utilities.TweaksCommandExecutor.RunCommandAsTrustedInstaller($"/c icacls \"{path}\" /grant {Environment.UserName}:F");CommandExecutor.RunCommandAsTrustedInstaller($"/c rd /s /q \"{path}\"");- Thread.Sleep(1000);+ Thread.Sleep(2000);if (Directory.Exists(path)){+ try { Directory.Delete(path, true); } catch (Exception ex) { ErrorLogging.LogDebug(ex); }TakingOwnership.GrantAdministratorsAccess(path, TakingOwnership.SE_OBJECT_TYPE.SE_FILE_OBJECT);CommandExecutor.RunCommandAsTrustedInstaller($"/c rd /s /q \"{path}\"");+ Thread.Sleep(2000);}}diff --git a/.Source/GTweak/View/MoreView.xaml.cs b/.Source/GTweak/View/MoreView.xaml.csindex 73b6985c..f0f8f696 100644--- a/.Source/GTweak/View/MoreView.xaml.cs+++ b/.Source/GTweak/View/MoreView.xaml.cs@@ -54,7 +54,7 @@ namespace GTweak.View}BackgroundQueue backgroundQueue = new BackgroundQueue();- await backgroundQueue.QueueTask(delegate { ClearingMemory.StartMemoryCleanupAsync(_isWinOldRemoval); });+ await backgroundQueue.QueueTask(delegate { ClearingMemory.StartMemoryCleanup(_isWinOldRemoval); });await backgroundQueue.QueueTask(delegate { new NotificationManager(500).Show("info", "clear_ram_notification").Perform(); });}