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

C#中调用System.Diagnostics.Process.Start无法打开链接的问题求助

Fixing "The system cannot find the file specified" When Using Process.Start to Open a URL

Hey, I’ve dealt with this exact error on Windows 10 and Visual Studio before—let’s walk through the most likely fixes and check other potential issues:

First: Fix the Core .NET Configuration Issue

The #1 reason for this error in modern .NET (Core/.NET 5+) is that the default behavior of Process.Start(string) has changed. When you pass a URL directly, it treats the URL as an executable file path (since UseShellExecute defaults to false), which obviously doesn’t exist.

Here’s the corrected code that forces the system to use your default browser:

using System.Diagnostics;

var startInfo = new ProcessStartInfo("http://google.com")
{
    UseShellExecute = true
};
Process.Start(startInfo);

This tells the OS to use its default shell (which handles URL-to-browser associations) instead of trying to run the URL as an executable. This should resolve the error in most cases.

If That Doesn’t Work: Check Other Potential Issues

Let’s rule out other scenarios, including your proxy environment suspicion:

  • Test the system shell directly: Open Command Prompt and run start http://google.com. If this fails, the issue is with your system’s ability to open URLs via the shell (not your code). If it works, your code was the problem.
  • Proxy environment impact: A strict proxy might block the browser from launching or resolving the URL, but this usually throws a different error (like a connection timeout) instead of "file not found". However, you can check your proxy settings in Windows Settings → Network & Internet → Proxy, and ensure your default browser is configured to use the proxy correctly.
  • Broken default browser association: Sometimes Windows loses track of which browser to use for URLs. Reset this by going to Settings → Apps → Default Apps, find "Web browser", reselect your preferred browser, then retest your code.
  • Visual Studio permissions: Try running Visual Studio as an administrator (right-click → "Run as administrator") and debugging again. Rarely, restricted permissions can prevent the process from launching the shell.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.21 06:26:34