34

I've got a VB.NET WinForms app in which I have the need to refer the user to a web page with documentation/help. I realize the LinkButton would get the trick done, but what I want is a standard Button control to launch the system default browser when that button is clicked. The only code I can find references the Win32 API, hooking the ShellExecute command:

ShellExecute(Me.Handle.ToInt32, "Open", "http://www.stackoverflow.com/", CStr(0), CStr(0), WindowStyle.SW_MAXIMIZE)

Does anyone else know how to do this in a "proper and pure" .NET manner?

Mike C.
  • 4,917
  • 8
  • 34
  • 38

1 Answers1

67
System.Diagnostics.Process.Start("http://www.website.com");

should work

Abel
  • 56,041
  • 24
  • 146
  • 247
FallenAvatar
  • 4,079
  • 1
  • 21
  • 24
  • Is there a way to check if the link has been launched or not? – Ali123 Dec 05 '19 at 13:05
  • @Ali123 Using this method, No. And I don't know of another reliable method to achieve that. – FallenAvatar Dec 30 '19 at 05:55
  • Hi FallenAvatar, thanks for your answer. I found out how to check if the process started. check the first comment here https://stackoverflow.com/questions/59196207/confirm-that-the-url-was-launched-successfully-in-c-sharp#comment104708278_59196207 – Ali123 Dec 30 '19 at 06:21
  • 1
    I get an exception `System.ComponentModel.Win32Exception (2): An error occurred trying to start process '` – pauloya Oct 22 '22 at 12:35
  • 1
    This solves my `Win32Exception` problem: https://stackoverflow.com/a/62534375/44547 – pauloya Oct 22 '22 at 12:39
  • 1
    System.Diagnostics.Process.Start (url); not working in .Net Core 3.1 – Ishrar Nov 02 '22 at 11:59