Passing in a file to a browser...

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Robert

    Passing in a file to a browser...

    I am creating a small help browser. It is pretty much finished except I
    cannot find how to pass a file to it (i.e. browser.exe index.html, or any
    html file, and the html file opens in the browser) from the command line.

    Pointers would help. : )

    Bob


  • Cor Ligthert

    #2
    Re: Passing in a file to a browser...

    Hi Robert,

    Strange Herfried did not answer this one because it looks to me that you are
    only asking this one

    \\\
    Dim psi As New ProcessStartInf o
    psi.FileName = "http://www.bla.foo"
    psi.UseShellExe cute = True
    Process.Start(p si)
    ///

    When you are longer on this newsgroup you recognise the typical Herfried
    code.

    However maybe I am wrong?

    Cor


    Comment

    • Robert

      #3
      Re: Passing in a file to a browser...

      "Cor Ligthert" <notfirstname@p lanet.nl> wrote in message
      news:eJ%23TQLwP EHA.4036@TK2MSF TNGP12.phx.gbl. ..[color=blue]
      > Hi Robert,
      >
      > Strange Herfried did not answer this one because it looks to me that you[/color]
      are[color=blue]
      > only asking this one
      >
      > \\\
      > Dim psi As New ProcessStartInf o
      > psi.FileName = "http://www.bla.foo"
      > psi.UseShellExe cute = True
      > Process.Start(p si)
      > ///
      >
      > When you are longer on this newsgroup you recognise the typical Herfried
      > code.
      >
      > However maybe I am wrong?
      >
      > Cor[/color]

      Thanks. That hardcodes the filename? I was looking to be able to launch any
      HTML file from the command line. But it gives me a start to work from...[color=blue]
      >
      >[/color]


      Comment

      • Jay B. Harlow [MVP - Outlook]

        #4
        Re: Passing in a file to a browser...

        Robert,
        Try:

        Public Module MainModule
        Public Sub Main(ByVal args() As String)[color=blue][color=green]
        > > Dim psi As New ProcessStartInf o
        > > psi.FileName = args(0)
        > > psi.UseShellExe cute = True
        > > Process.Start(p si)[/color][/color]
        End Sub
        End Module

        Hope this helps
        Jay

        "Robert" <catcher@linuxm ail.org> wrote in message
        news:%23lAGGizP EHA.1048@tk2msf tngp13.phx.gbl. ..[color=blue]
        > "Cor Ligthert" <notfirstname@p lanet.nl> wrote in message
        > news:eJ%23TQLwP EHA.4036@TK2MSF TNGP12.phx.gbl. ..[color=green]
        > > Hi Robert,
        > >
        > > Strange Herfried did not answer this one because it looks to me that you[/color]
        > are[color=green]
        > > only asking this one
        > >
        > > \\\
        > > Dim psi As New ProcessStartInf o
        > > psi.FileName = "http://www.bla.foo"
        > > psi.UseShellExe cute = True
        > > Process.Start(p si)
        > > ///
        > >
        > > When you are longer on this newsgroup you recognise the typical Herfried
        > > code.
        > >
        > > However maybe I am wrong?
        > >
        > > Cor[/color]
        >
        > Thanks. That hardcodes the filename? I was looking to be able to launch[/color]
        any[color=blue]
        > HTML file from the command line. But it gives me a start to work from...[color=green]
        > >
        > >[/color]
        >
        >[/color]


        Comment

        • Robert

          #5
          [More Info] Re: Passing in a file to a browser...

          Maybe I am doing something wrong so I am going to be more verbose. I need to
          created a minimal browser to view some help files that are in HTML. I
          created a standard Windows form and put the AxWebBrowser control on it as
          well as a toolbar with "back", "forward", and "exit". I can drag and drop an
          HTML file on the running application and it renders the page and I can move
          back and forth with my nav buttons. I cannot (even using the snippet you
          gave) pass an HTML page via the command line and have the AxWebBrowser
          control display it.

          Without going in to much detail. We have a 3rd party application that
          currently opens IE to view its help files (which opens holes we do not want
          to deal with) so I intend to "replace" IE with my little help browser and
          make all the big wigs happy. And learn VB.NET is the process! : )


          Comment

          • Cor Ligthert

            #6
            Re: [More Info] Re: Passing in a file to a browser...

            Hi Robert,

            This seems to me a total different approach, you did something as this

            Open a new windows application project

            In the toolbox rightclick and select add/Remove items

            In the customize toolbox select Com and in that Microsoft Webbrowser

            When that is in the toolbox drag it to your form
            Drag also a button to your form.

            Then this code and you have a mini Webbrowser.

            Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
            System.EventArg s) Handles Button1.Click
            Me.AxWebBrowser 1.Navigate2("ww w.google.com")
            End Sub

            While that www.google.com can be a textbox of course or your html file.

            A very complete sample is here.

            webbrowser
            Microsoft Support is here to help you with Microsoft products. Find how-to articles, videos, and training for Microsoft Copilot, Microsoft 365, Windows, Surface, and more.


            And what more documentation.
            mshtml



            Comment

            • Robert

              #7
              Re: [More Info] Re: Passing in a file to a browser...

              "Cor Ligthert" <notfirstname@p lanet.nl> wrote in message
              news:eyjBnN0PEH A.3596@tk2msftn gp13.phx.gbl...[color=blue]
              > Hi Robert,
              >
              > This seems to me a total different approach, you did something as this
              >
              > Open a new windows application project
              >
              > In the toolbox rightclick and select add/Remove items
              >
              > In the customize toolbox select Com and in that Microsoft Webbrowser
              >
              > When that is in the toolbox drag it to your form
              > Drag also a button to your form.
              >
              > Then this code and you have a mini Webbrowser.
              >
              > Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
              > System.EventArg s) Handles Button1.Click
              > Me.AxWebBrowser 1.Navigate2("ww w.google.com")
              > End Sub
              >
              > While that www.google.com can be a textbox of course or your html file.
              >
              > A very complete sample is here.
              >
              > webbrowser
              > http://support.microsoft.com/?kbid=311303
              >
              > And what more documentation.
              > mshtml
              >[/color]
              http://msdn.microsoft.com/library/de...ng/hosting.asp[color=blue]
              >
              >[/color]
              Right. Like I said I have it almost completed. It does not (and the examples
              above do not) allow me to pass an HTML file from the command line. I can
              drop an HTML file on the running app and that works. I would also not like
              to have to hard code a path. I am new to VB.NET so maybe I am not focusing
              my thoughts correctly. : )


              Comment

              • Jay B. Harlow [MVP - Outlook]

                #8
                Re: [More Info] Re: Passing in a file to a browser...

                Robert,
                You did notice that my sample allowed you to pass a file from the command
                line?

                There are a number of methods to pass parameters to your program, I prefer
                the Main(args) method

                Public Sub Main(ByVal args() As String)
                End Sub

                If you have an embeded browser you could do something like:

                Public Class MainForm
                Inherits Form

                Public Shared Sub Main(ByVal args() As String)
                Dim mainForm As New MainForm
                mainForm.AxWebB rowser1.Navigat e2(args(0))
                Application.Run (mainForm)
                End Sub

                End Class

                Alternatively you can use the VB.NET Command() function to load the browser:
                [color=blue][color=green]
                > > Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
                > > System.EventArg s) Handles Button1.Click
                > > Me.AxWebBrowser 1.Navigate2(Com mand())
                > > End Sub[/color][/color]

                Still another method would be to use either System.Environm ent.CommandLine
                or System.Environm ent.GetCommandL ineArgs().
                [color=blue][color=green]
                > > Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
                > > System.EventArg s) Handles Button1.Click
                > > Me.AxWebBrowser 1.Navigate2(Env ironment.Comman dLine)
                > > End Sub[/color][/color]

                I would use Environment.Com mandLine if I wanted to parse the complete
                command line myself, otherwise I would use Environment.Get CommandLineArgs ()
                which seperates the command line into individual string tokens... However I
                mostly use the Sub Main(args() As String) method.

                Hope this helps
                Jay




                "Robert" <catcher@linuxm ail.org> wrote in message
                news:eAKr6X3PEH A.3708@TK2MSFTN GP10.phx.gbl...[color=blue]
                > "Cor Ligthert" <notfirstname@p lanet.nl> wrote in message
                > news:eyjBnN0PEH A.3596@tk2msftn gp13.phx.gbl...[color=green]
                > > Hi Robert,
                > >
                > > This seems to me a total different approach, you did something as this
                > >
                > > Open a new windows application project
                > >
                > > In the toolbox rightclick and select add/Remove items
                > >
                > > In the customize toolbox select Com and in that Microsoft Webbrowser
                > >
                > > When that is in the toolbox drag it to your form
                > > Drag also a button to your form.
                > >
                > > Then this code and you have a mini Webbrowser.
                > >
                > > Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
                > > System.EventArg s) Handles Button1.Click
                > > Me.AxWebBrowser 1.Navigate2("ww w.google.com")
                > > End Sub
                > >
                > > While that www.google.com can be a textbox of course or your html file.
                > >
                > > A very complete sample is here.
                > >
                > > webbrowser
                > > http://support.microsoft.com/?kbid=311303
                > >
                > > And what more documentation.
                > > mshtml
                > >[/color]
                >[/color]
                http://msdn.microsoft.com/library/de...ng/hosting.asp[color=blue][color=green]
                > >
                > >[/color]
                > Right. Like I said I have it almost completed. It does not (and the[/color]
                examples[color=blue]
                > above do not) allow me to pass an HTML file from the command line. I can
                > drop an HTML file on the running app and that works. I would also not like
                > to have to hard code a path. I am new to VB.NET so maybe I am not focusing
                > my thoughts correctly. : )
                >
                >[/color]


                Comment

                • Robert

                  #9
                  Re: [More Info] Re: Passing in a file to a browser...

                  "Jay B. Harlow [MVP - Outlook]" <Jay_Harlow_MVP @msn.com> wrote in message
                  news:OXddSI4PEH A.3348@TK2MSFTN GP09.phx.gbl...[color=blue]
                  > Robert,
                  > You did notice that my sample allowed you to pass a file from the command
                  > line?
                  >
                  > There are a number of methods to pass parameters to your program, I prefer
                  > the Main(args) method
                  >
                  > Public Sub Main(ByVal args() As String)
                  > End Sub
                  >
                  > If you have an embeded browser you could do something like:
                  >
                  > Public Class MainForm
                  > Inherits Form
                  >
                  > Public Shared Sub Main(ByVal args() As String)
                  > Dim mainForm As New MainForm
                  > mainForm.AxWebB rowser1.Navigat e2(args(0))
                  > Application.Run (mainForm)
                  > End Sub
                  >
                  > End Class
                  >
                  > Alternatively you can use the VB.NET Command() function to load the[/color]
                  browser:[color=blue]
                  >[color=green][color=darkred]
                  > > > Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
                  > > > System.EventArg s) Handles Button1.Click
                  > > > Me.AxWebBrowser 1.Navigate2(Com mand())
                  > > > End Sub[/color][/color]
                  >
                  > Still another method would be to use either System.Environm ent.CommandLine
                  > or System.Environm ent.GetCommandL ineArgs().
                  >[color=green][color=darkred]
                  > > > Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
                  > > > System.EventArg s) Handles Button1.Click
                  > > > Me.AxWebBrowser 1.Navigate2(Env ironment.Comman dLine)
                  > > > End Sub[/color][/color]
                  >
                  > I would use Environment.Com mandLine if I wanted to parse the complete
                  > command line myself, otherwise I would use[/color]
                  Environment.Get CommandLineArgs ()[color=blue]
                  > which seperates the command line into individual string tokens... However[/color]
                  I[color=blue]
                  > mostly use the Sub Main(args() As String) method.
                  >
                  > Hope this helps
                  > Jay
                  >
                  >
                  >
                  >
                  > "Robert" <catcher@linuxm ail.org> wrote in message
                  > news:eAKr6X3PEH A.3708@TK2MSFTN GP10.phx.gbl...[color=green]
                  > > "Cor Ligthert" <notfirstname@p lanet.nl> wrote in message
                  > > news:eyjBnN0PEH A.3596@tk2msftn gp13.phx.gbl...[color=darkred]
                  > > > Hi Robert,
                  > > >
                  > > > This seems to me a total different approach, you did something as this
                  > > >
                  > > > Open a new windows application project
                  > > >
                  > > > In the toolbox rightclick and select add/Remove items
                  > > >
                  > > > In the customize toolbox select Com and in that Microsoft Webbrowser
                  > > >
                  > > > When that is in the toolbox drag it to your form
                  > > > Drag also a button to your form.
                  > > >
                  > > > Then this code and you have a mini Webbrowser.
                  > > >
                  > > > Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
                  > > > System.EventArg s) Handles Button1.Click
                  > > > Me.AxWebBrowser 1.Navigate2("ww w.google.com")
                  > > > End Sub
                  > > >
                  > > > While that www.google.com can be a textbox of course or your html[/color][/color][/color]
                  file.[color=blue][color=green][color=darkred]
                  > > >
                  > > > A very complete sample is here.
                  > > >
                  > > > webbrowser
                  > > > http://support.microsoft.com/?kbid=311303
                  > > >
                  > > > And what more documentation.
                  > > > mshtml
                  > > >[/color]
                  > >[/color]
                  >[/color]
                  http://msdn.microsoft.com/library/de...ng/hosting.asp[color=blue][color=green][color=darkred]
                  > > >
                  > > >[/color]
                  > > Right. Like I said I have it almost completed. It does not (and the[/color]
                  > examples[color=green]
                  > > above do not) allow me to pass an HTML file from the command line. I can
                  > > drop an HTML file on the running app and that works. I would also not[/color][/color]
                  like[color=blue][color=green]
                  > > to have to hard code a path. I am new to VB.NET so maybe I am not[/color][/color]
                  focusing[color=blue][color=green]
                  > > my thoughts correctly. : )
                  > >
                  > >[/color]
                  >
                  >[/color]
                  Thanks!!!


                  Comment

                  Working...