0

I would like to create simple exe app in VB, which will open default browser with specified page. I have this code

Public Class Form1
Private Sub Label1_Click(sender As Object, e As EventArgs) Handles Label1.Click

End Sub

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    System.Diagnostics.Process.Start("www.google.com")
End Sub  End Class

If I click on the button I get error message:

System.ComponentModel.Win32Exception: System cannot find this file

Could someone help me where is the problem? Or is there any other approach how to open webpage?

pomahajbo
  • 1
  • 1
  • I believe in Windows the protocol (https) is assosiated with an application (browser) so try with https://, don't know how to make to comment so that it doesn't remove my protocol from link :) – Esko Nov 16 '21 at 12:21
  • @Esko same problem with https:// :/ – pomahajbo Nov 16 '21 at 12:25
  • Just tested with Framework 4.8 and it works fine with https://-start. Check that your pc has default protocol for https in Windows. – Esko Nov 16 '21 at 12:42
  • @Esko hmm, i think the settings are correct :/ – pomahajbo Nov 16 '21 at 13:26

2 Answers2

1

"System cannot find this file" means that your system is not reading the URL as one and it's trying to get the resource at the local path: "www.google.com" which obviously doesn't exist. Check this link because the issue seems to be the same.

Lorenzo Martini
  • 373
  • 1
  • 8
0

Here in an application I call Best Links is the process I use to view URL's.
It works by storing website URL links in a SQLite Database (DB).
The DB also stores the Site Name and the Last Visit Date.To view the site the user just clicks on the DB entry displayed in DataGridView. Screen Shot Below. And the code that opens the link in what ever your default browser is.

 Private Sub dgvLinks_CellClick(sender As System.Object, e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgvLinks.CellClick

    selRow = e.RowIndex

    If e.RowIndex = -1 Then
        gvalertType = "4"
        frmAlert.ShowDialog()
        Exit Sub
    End If

    Dim row As DataGridViewRow = Me.dgvLinks.Rows(e.RowIndex)
    If row.Cells(2).Value Is Nothing Then
        gvalertType = "5"
        frmAlert.ShowDialog()
        Return
        Exit Sub
    ElseIf gvTxType = "View" Then
        webPAGE = row.Cells(2).Value.ToString()
        siteID = CInt(row.Cells(0).Value.ToString())

        UpdateSiteData()

        Process.Start(webPAGE)

Data Grid View

If you would like the complete code or and exe file let me know and I will add it to my GitHub repository code will be a ZIP file.

Vector
  • 3,066
  • 5
  • 27
  • 54