Avatar of LoGa1234567890
LoGa1234567890
 asked on

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
            DoEvents
        Loop
    Loop
    Text1 = CDate(IE.Document.getElementById("t1").InnerText)
    IE.Quit
    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 ?

Thanks
Visual Basic Classic

Avatar of undefined
Last Comment
LoGa1234567890

8/22/2022 - Mon
ethanw023

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.
Chris Ashcraft

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.
DGM87

Yeah, because the code is looking for IE, so it's pulling it up.  What Micropc said should do it.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
LoGa1234567890

ASKER
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" ?
Chris Ashcraft

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.
http://www.robvanderwoude.com/regedit.php
LoGa1234567890

ASKER
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 !
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
ASKER CERTIFIED SOLUTION
Chris Ashcraft

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
LoGa1234567890

ASKER
Thanks ! micropc1, your code works perfectly.