• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 717
  • Last Modified:

Default browser

Hi Experts,

Every time I run the following code, since the internet explorer is not my default browser, the message "Internet Explorer is not currently your default browser. Would you like to make it your default browser?" always comes up.

Private Sub Command1_Click()
Text1 = ""
    Dim IE As Object
    Set IE = CreateObject("InternetExplorer.Application")
    IE.Navigate "http://free.timeanddate.com/clock/i1up141f/n240/tt1/tw0/tm2"
    IE.Toolbar = False
    IE.StatusBar = False
    IE.MenuBar = False
    Do While IE.Busy
        Do While IE.Busy
    Text1 = CDate(IE.Document.getElementById("t1").InnerText)
    Set IE = Nothing
End Sub

How can I suppress or bypass that message with the Internet Explorer as the browser to get the result I want in Text1 ?
or how to use the default browser so the message above would not appear to get the same result in text1 ?

1 Solution
In Internet Explorer options, click Programs, in there is a checkbox that says "Tell me if Internet Explorer is not the default browser", uncheck that.
I'm assuming you're wanting to not require any user interaction, which is why you didn't just click "Yes" to set IE as the default browser in the first place... Have your VB code set the registry key "\HKLM\Software\Microsoft\Internet Explorer\Main\Check_Associations" to a REG_SZ value of "no". This will prevent IE from checking if it is the default browser and prevent the prompt from appearing.
Yeah, because the code is looking for IE, so it's pulling it up.  What Micropc said should do it.
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

LoGa1234567890Author Commented:
Thank you for the prompt reply !

How to code vb6 to set the registry key "\HKLM\Software\Microsoft\Internet Explorer\Main\Check_Associations" to a REG_SZ value of "no" ?
This may help... http://www.ex-designz.net/apidetail.asp?api_id=183

Another option would be to use the shell command to run regedit.exe and import a .reg file.
LoGa1234567890Author Commented:
Hi micropc1,

Using regedit and open the Registry Editor, I can get it work with HKEY_CURRENT_USER, ( I tried HKEY_LOCAL_MACHINE, but not work).

I tried to run the following code in form_load to let vb do this job , but got error in line 5 (Set objAccount----)

Dim strComputer, strUserDN, strUserDomain, checkAssociations As String
Dim WshShell, objShell, objWMIService, objAccount As Object
  strComputer = "."
  Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
  Set objAccount = objWMIService.Get("Win32_UserAccount.Name='" & strUserDN & "',Domain='" & strUserDomain & "'")
  MsgBox (strUserDN & " SID = " & objAccount.SID)
  'Read for existing SID entry for Check_Associations
  checkAssociations = "Yes"
  checkAssociations = WshShell.RegRead("HKEY_USERS\" & objAccount.SID & "\Software\Microsoft\Internet Explorer\Main\Check_Associations")
  If checkAssociations <> "No" Then
'    Create desired reg entry
    objShell.RegWrite "HKEY_USERS\" & objAccount.SID & "\Software\Microsoft\Internet Explorer\Main\Check_Associations", "No", "REG_SZ"
  End If

Please help !
Sorry, I believe I was mistaken about HKLM...just tested it and it doesn't work. Looks like HKCU is what you want.

Try this...

Dim strComputer, CAKey, checkAssociations As String
Dim WshShell

Set WshShell = CreateObject("Wscript.Shell")
CAKey = "HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\Check_Associations"

If WshShell.RegRead(CAKey) <> "No" Then
    WshShell.RegWrite CAKey, "No", "REG_SZ"
End If

Open in new window

LoGa1234567890Author Commented:
Thanks ! micropc1, your code works perfectly.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now