WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

URLs - Web - Browser Topics

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Methods to Determine What Browser is Installed

Keywords:     netscape internet explorer browser

Question:

How do I determine what browser is installed on a given machine?

Answer:

Here are two methods:

  1. In the first approach below, the Internet Shortcut file needs to have the following form (like an INI file):
    	[DEFAULT]
    	BASEURL=http://www.whereever.com/somepage.htm
    
    	[InternetShortcut]
    	URL=http://www.whereever.com/somepage.htm
    
    accomplished with the following code:
    
    	temp=Environment("TEMP")
    	if temp=="" then temp=Environment("TMP")
    	if temp=="" then temp="C:\"
    
    	where="http://www.yahoo.com/"
    
    	if strsub(temp,strlen(temp),1)!="\"
    		temp=strcat(temp,"\")
    	endif
    
    	url=strcat(temp,"$xyz.url")
    
    	xxx=FileOpen(url,"WRITE")
    		
    		FileWrite(xxx,"[DEFAULT]")
    		FileWrite(xxx,strcat("BASEURL=",where))
    		FileWrite(xxx,"[InternetShortCut]")
    		FileWrite(xxx,strcat("URL=",where))
    
    	FileClose(xxx)
    
    	ShellExecute(url,"","",@NORMAL,"OPEN")
    
    But I don't think NT 3.51 will pick up on that. You have to figure out the browser name and launch it like:
    	run("c:\program files\netscape\communicator\programs\netscape.exe","http://www.yahoo.com")
    

  2. Another alternative:
    BrowserExe=StrUpper(RegQueryValue(@REGMACHINE,"SOFTWARE\Classes\HTTP\Shell\Open\ddeexec\Application\[]"))
    Message("Default Browser",BrowserExe)
    Run(BrowserExe,"")
    Message("Finished","Default Browser Launched")
    

  3. Or, another approach would be something like...
    ;WARNING WARNING NEVER NEVER
    ;JUST SET ERRORMODE(@OFF) AT THE TOP OF YOUR SCRIPT
    ;IT CAN PUT YOUR COMPANY OUT OF BUSINESS!!!
    ;MAKE SURE TO ISOLATE ITS USAGE AROUND A COUPLE OF LINES OF CODE, AS BELOW:
    
    Errormode(@off)
    
    ;HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\Netscape.exe
    netscape=RegQueryValue(@RegMachine,"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\Netscape.exe[]")
    ;HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\IEXPLORE.EXE
    iexplorer=RegQueryValue(@RegMachine,"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\IEXPLORE.EXE[]")
    
    ErrorMode(@CANCEL)
    
    
    if netscape!=0
           run(netscape,"")
    else
           if iexplorer!=0
              run(iexplorer,"")
           else
              Message("Ooopsie","Browser not found")
           endif
    endif
    exit
    

Article ID:   W13346
Filename:   Determine what Browser is Installed.txt
File Created: 2003:12:04:08:54:28
Last Updated: 2003:12:04:08:54:28