You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Windows 11中C#调用Explorer.exe闪退但进程残留的技术问题

Windows 11下C#启动资源管理器窗口闪闭问题解决办法

问题根源

设置UseShellExecute = false会让Explorer.exe以非Shell关联的方式启动,它无法正确加载Windows Shell环境,导致前台窗口短暂显示后关闭,但进程会在后台保持活跃。

修复方案

方案1:启用ShellExecute(推荐)

将UseShellExecute设为true(这是默认值,可直接省略该配置),让系统通过Shell环境启动资源管理器:

var startInfo = new System.Diagnostics.ProcessStartInfo();
startInfo.FileName = "explorer.exe";
startInfo.Arguments = "D:\\";
System.Diagnostics.Process.Start(startInfo);

更简洁的写法:

System.Diagnostics.Process.Start("explorer.exe", "D:\\");

方案2:调整参数格式(兼容非Shell启动场景)

如果必须保持UseShellExecute = false,需要给Explorer传递带/e,前缀的路径参数:

var startInfo = new System.Diagnostics.ProcessStartInfo();
startInfo.FileName = "C:\\Windows\\explorer.exe";
startInfo.WorkingDirectory = "C:\\Windows";
startInfo.UseShellExecute = false;
startInfo.Arguments = "/e,D:\\";
System.Diagnostics.Process.Start(startInfo);

注意:此方案存在系统兼容性风险,优先使用方案1。

补充说明

  • Explorer.exe高度依赖Windows Shell环境,UseShellExecute = true能确保进程加载完整的Shell上下文,窗口正常显示。
  • 无需手动指定WorkingDirectory,Explorer会自动识别参数中的路径并定位到目标文件夹。

内容的提问来源于stack exchange,提问作者Yassin alaoui

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.29 07:17:10