0

How do I open a URL using the computer's default browser in VB .NET?
I have searched on the internet and found:

Dim URL As String = "http://www.google.com/"
Process.Start(URL)

Or just:

Procecss.Start("google.com")

But all these are not working. For these 2, it says "system cannot find path specified"
I am using Visual Studio Community 2019

sighclone
  • 102
  • 1
  • 10
  • 1
    You forgot to mention the .Net version you're using. If it's .Net Core or .Net 5, it's slightly different, because the some *defaults* are different. – Jimi Mar 26 '21 at 18:00
  • I'm using .Net core, I found the solution though. Thanks for your time. – sighclone Mar 26 '21 at 18:04
  • Does this answer your question? [How to open in default browser in C#](https://stackoverflow.com/questions/4580263/how-to-open-in-default-browser-in-c-sharp) – GSerg Mar 26 '21 at 18:25
  • `all these are not working` - should have [read the comments](https://stackoverflow.com/questions/4580263/how-to-open-in-default-browser-in-c-sharp#comment113060356_4580324) and [scroll down](https://stackoverflow.com/a/4580317/11683) a bit. – GSerg Mar 26 '21 at 18:27
  • I did that too however I thought since it is C# it would be irrelevant, but now I seem to find similarities. – sighclone Mar 28 '21 at 04:23

1 Answers1

0

You need to edit path variables and make the path of the browser visible to the program.

Or, you could specify the path in the code like:

Process.Start("<browser.exe file path>", "example.com")
sighclone
  • 102
  • 1
  • 10
  • 2
    You can use a `ProcessStartInfo` object and set `UseShellExecute = true`. So you don't need to know which is the default WebBrowser of find its executable path. – Jimi Mar 26 '21 at 18:05
  • If your problem has been solved, please consider [accepting it](https://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work). – Xingyu Zhao Apr 01 '21 at 07:05
  • @Jimi I have tried it but I get the following error: System.NullReferenceException: 'Object reference not set to an instance of an object.' – sighclone Apr 05 '21 at 14:19