4

If I try to use:

System.Diagnostics.Process.Start("http://google.com");

the following error occurs:

System.ComponentModel.Win32Exception: "The system cannot find the file specified"

I use win10 and visual studio.

Actually I can't find a solution or something like that. Maybe it's because i'm behind a proxy ? Or could there be any other problem ? And if yes, could you help me to fix it ?

5
  • @derloopkat,no,System.Diagnostics.Process.Start can open links in your default web application too Commented Mar 28, 2018 at 8:29
  • If you're using .Net Core, this answer might be of use Commented Mar 28, 2018 at 8:31
  • Cannot reproduce. That code works as expected Commented Mar 28, 2018 at 8:31
  • @Steve that's the problem.. I think if this error was normal, I could find a solution in another Thread :P Commented Mar 28, 2018 at 8:34
  • If you can't make it work then you have some kind of problem in your machine where there is no association between these links and your default browser. Glad you have found a workaround Commented Mar 28, 2018 at 8:47

2 Answers 2

12

Can you try below work around:

System.Diagnostics.Process.Start("cmd","/c start http://www.google.com"); 
Sign up to request clarification or add additional context in comments.

3 Comments

@Morta: I just applied another approach. you can find more details on ss64.com/nt/start.html
@Morta,take a look at my solution :) and SpiderCoder, upvote deserved
Thanks this solution helped me, i found you can also use System.Diagnostics.Process.Start(new ProcessStartInfo("http://google.com"){ UseShellExecute=true});
1

I think I should document this here since I haven't seen many answers explaining why that error happens

The actual problem you are facing is that you are using the incorrect overload. The only parameter accepted by this overload is a file or document name. According to MSDN, URLs are NOT consider documents.

You find that statement hidden in one of the examples in the documentation here...

https://msdn.microsoft.com/en-us/library/53ezey2s(v=vs.110).aspx

enter image description here

Now, the correct overload is...

System.Diagnostics.Process.Start(string fileName, string arguments); 

where filename is name of the process you want to start (IE, Chrome, etc.) and arguments in this case would be the URL to pass to the process. More infor here...

https://msdn.microsoft.com/en-us/library/h6ak8zt5(v=vs.110).aspx

1 Comment

Thank you. But actually, if I use Process.Start("IExplore.exe", "www.google.com");, the same error occurs..

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.