From 33018e1a90d8c13770e648ce077718cf9fab8220 Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Fri, 27 Mar 2026 21:33:19 +0800 Subject: [PATCH] Remove manual restart of explorer.exe after kill Windows automatically restarts explorer.exe after it is killed, so removed the code that manually started a new explorer.exe process. Also removed unnecessary Thread.Sleep calls and updated comments to clarify this behavior. --- .../BluePointLilac.Methods/ExternalProgram.cs | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/ContextMenuManager/BluePointLilac.Methods/ExternalProgram.cs b/ContextMenuManager/BluePointLilac.Methods/ExternalProgram.cs index 89af4c90..6e337294 100644 --- a/ContextMenuManager/BluePointLilac.Methods/ExternalProgram.cs +++ b/ContextMenuManager/BluePointLilac.Methods/ExternalProgram.cs @@ -215,15 +215,7 @@ public static void RestartExplorer() } } - // 等待一小段时间确保所有进程已完全退出 - Thread.Sleep(500); - - // 启动新的 explorer.exe 进程 - Process.Start(new ProcessStartInfo - { - FileName = "explorer.exe", - UseShellExecute = true - })?.Dispose(); + // 无需启动新的 explorer.exe 进程,Windows 会自动重启它 } catch (Exception ex) when ( ex is Win32Exception or @@ -245,12 +237,8 @@ InvalidOperationException or { kill?.WaitForExit(); } - Thread.Sleep(500); - Process.Start(new ProcessStartInfo - { - FileName = "explorer.exe", - UseShellExecute = true - })?.Dispose(); + + // 无需启动新的 explorer.exe 进程,Windows 会自动重启它 } catch (Exception ex1) when ( ex1 is Win32Exception or