Free, open-source Windows optimization tool for performance, privacy, and simplicity.
C# csharpdebloatdotnetgamingopen-sourceoptimizationoptimizeroptimizerduckperformanceprivacytweakertweakswindowswinui
feat(SystemRefreshService): add RestartExplorer methods
fatDuckf77e46fe34a6
diff --git a/optimizerDuck/Common/Helpers/SystemRefreshService.cs b/optimizerDuck/Common/Helpers/SystemRefreshService.csindex 4ff0b69..41b8507 100644--- a/optimizerDuck/Common/Helpers/SystemRefreshService.cs+++ b/optimizerDuck/Common/Helpers/SystemRefreshService.cs@@ -1,3 +1,4 @@+using System.Diagnostics;using System.Runtime.InteropServices;namespace optimizerDuck.Common.Helpers;@@ -54,4 +55,35 @@ internal static class SystemRefreshService{SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, IntPtr.Zero, IntPtr.Zero);}++ /// <summary>+ /// As a last resort, if targeted refreshes don't work, we can restart Explorer+ /// </summary>+ public static void RestartExplorer()+ {+ Process.Start(new ProcessStartInfo+ {+ FileName = "cmd.exe",+ Arguments = "/c taskkill /f /im explorer.exe && start explorer.exe",+ CreateNoWindow = true,+ UseShellExecute = false,+ });+ }++ /// <summary>+ /// As a last resort, if targeted refreshes don't work, we can restart Explorer+ /// </summary>+ public static Task RestartExplorerAsync()+ {+ return Task.Run(() =>+ {+ Process.Start(new ProcessStartInfo+ {+ FileName = "cmd.exe",+ Arguments = "/c taskkill /f /im explorer.exe && start explorer.exe",+ CreateNoWindow = true,+ UseShellExecute = false,+ });+ });+ }}