• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 704
  • 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
            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
0
LoGa1234567890
Asked:
LoGa1234567890
1 Solution
 
ethanw023Commented:
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.
0
 
micropc1Commented:
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.
0
 
DGM87Commented:
Yeah, because the code is looking for IE, so it's pulling it up.  What Micropc said should do it.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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" ?
0
 
micropc1Commented:
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
0
 
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 !
0
 
micropc1Commented:
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

0
 
LoGa1234567890Author Commented:
Thanks ! micropc1, your code works perfectly.
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

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