How can i open mozila firefox using an exe in vb 6

Dani AI

Generated

Short answer: you can either start Firefox directly with VB6's Shell (as suggested) or, more robustly, ask Windows to open a URL with the default browser using ShellExecute. Below are ready-to-use VB6 examples and quick tips so it works reliably.

Use Shell to run firefox.exe (adjust the path if Firefox is in Program Files (x86) on 64-bit Windows):

' Launch Firefox directly (adjust path)
Dim pid As Long
pid = Shell("""C:\Program Files\Mozilla Firefox\firefox.exe"" ""http://www.example.com""", vbNormalFocus)

If you prefer letting Windows pick the default browser or simply opening an http(s) link, use ShellExecute (returns >32 on success):

Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
    (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, _
     ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

Dim result As Long
result = ShellExecute(0, "open", "http://www.example.com", vbNullString, vbNullString, vbNormalFocus)
If result <= 32 Then MsgBox "ShellExecute failed, error=" & result

Troubleshooting and notes:

  • Quote paths with spaces by doubling quotes inside the VB string (shown above).
  • To open a new tab or window use Firefox switches like -new-tab or -new-window before the URL. See Firefox command-line options for details.
  • Avoid hard-coding Program Files paths; if you must launch firefox.exe directly, detect the install location or check both Program Files and Program Files (x86).
  • Use ShellExecute when you want the system default browser behavior; use Shell when you need to pass Firefox-specific switches.

References: , ShellExecute (Win32 API), Firefox command-line options (MDN).

Recommended Answers

All 2 Replies

Try using SHELL.

open link ?????????

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.