Jaa


Starting a command line browser

Question: I have what may sound like a bit odd of a question that I am hoping you may be able to help with or point me in the right direction. There is a console application that is used in part of our application. It has been a fairly long time since I had to write one of these and it has been a definite challenge. There is one problem that I can’t seem to figure out. In part of the application I need to open a web page. Any ideas on how I can do this?

Answer: Long live the mighty console application! Within a console application the system.Diagnostics.Process.start function should do the trick. This starts the process associated with a string. In this case the browser when a URL is entered.

The following code is a simple example of accepting a URL entered by the user and the starting the browser.

 

Imports System.io

Module Module1

    Sub Main()

        Dim uIn As TextReader = Console.In

        Dim uOut As TextWriter = Console.Out

        uOut.WriteLine("Command Line Launcher")

        uOut.Write("Enter the URL to load: ")

        Dim name As String = uIn.ReadLine()

        '' Enter the URL - https://blogs.msdn.com/trobbins

        Process.Start(name)

    End Sub

End Module