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

Windows 11下C#调用explorer.exe闪退(进程留存)问题求助

Windows 11下C#启动资源管理器弹窗闪退问题解决

问题场景

在Windows 11中通过C#代码启动Windows资源管理器时,窗口短暂打开后立即关闭,但进程仍留在任务管理器中;相同代码在Windows 10可正常运行。

原代码:

var myFile = "C:\\Windows\\explorer.exe";
var workingFolder = "C:\\Windows";
var process = new ProcessStartInfo();
process.FileName = myFile;
process.WorkingDirectory = workingFolder;
process.UseShellExecute = false;
process.Arguments = "d:\\";
Process.Start(process);

解决方案

1. 启用UseShellExecute并调整参数格式

Windows 11对资源管理器的启动逻辑做了调整,当UseShellExecute=false时,资源管理器无法正确初始化UI界面。将UseShellExecute设为true,同时给路径参数添加/e,前缀(这是Windows 11资源管理器识别路径的标准格式):

var process = new ProcessStartInfo();
process.FileName = "explorer.exe";
process.WorkingDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Windows);
process.UseShellExecute = true;
process.Arguments = "/e, d:\\";
Process.Start(process);

2. 使用简化启动写法

无需手动配置过多参数,直接通过Process.Start传入目标路径,系统会自动调用资源管理器打开:

// 写法一
Process.Start("explorer.exe", @"d:\");
// 写法二(更简洁)
Process.Start(@"d:\");

3. 重置资源管理器进程

如果上述方法无效,可能是Windows 11资源管理器的进程状态异常:

  • 打开任务管理器,结束所有explorer.exe进程
  • 点击任务管理器的「文件」→「运行新任务」,输入explorer.exe回车恢复默认启动状态,之后再测试代码

内容的提问来源于stack exchange,提问作者Hamza El Hammoudi

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.01 16:27:04