Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

newbie Help: HOW to use VBSCript on clientside to detect browser type and version

404 views
Skip to first unread message

jharp80

unread,
Jun 14, 2009, 10:33:45 PM6/14/09
to
Hi I would like to detect broswer type and version (Example FF2, FF3,
IE, so on) on the client side using VBScript. I appreciate any script
on this I can do; and if not available some general guidelines how I
should accomplish this using VBSCript ;example what objects ı need to
query. or is it possible to do this through reading registry keys.

Thanks

Bob Barrows

unread,
Jun 15, 2009, 7:09:03 AM6/15/09
to
jharp80 wrote:
> Hi I would like to detect broswer type and version (Example FF2, FF3,
> IE, so on) on the client side using VBScript.

You will not be able to use vbscript with Firefox - it is not supported. You
will need to use javascript instead.

> I appreciate any script
> on this I can do; and if not available some general guidelines how I

> should accomplish this using VBSCript ;example what objects i need to


> query. or is it possible to do this through reading registry keys.
>

No registry keys are needed. DHTM should suffice. See:
http://www.dynamicdrive.com/dynamicindex9/browsersniffer.htm

--
Microsoft MVP - ASP/ASP.NET - 2004-2007
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


jharp80

unread,
Jun 15, 2009, 8:13:41 AM6/15/09
to

Thanks for your reply. I am interested in detecting only Firefox and
IE versions installed. And I like to do so without the browesers
actually launched.

I have an hta script; so the code that I am looking for to do the
detection will be included in that hta script written in VBScript.
There must be a way to detect firefox as well, the script you
mentioned seems to support detection of several broswers but Firefox
which is what I need along with IE. any other thoughts? Thanks.

mayayana

unread,
Jun 15, 2009, 8:54:03 AM6/15/09
to
When you say "client-side" that implies you're
talking about doing it through a visited webpage.
If it's an HTA with VBScript then you must mean
that you're running your HTA on a local PC. (You
can't do anything like what you're asking over the
Internet.)

For IE, a couple of tests that might be good:

1) The default value in this key should give you the
path to IE. You can then check the version of the file:

HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\App
Paths\IEXPLORE.EXE

2) This value provides the IE version:

HKEY_LOCAL_MACHINE\Software\Microsoft\Internet Explorer

The latter method may be less trustworthy. On my own
system, for instance, I installed an HP printer that
insisted I didn't have a recent enough version of IE. (!)
I had to change that Registry value to a higher
number in order to stop the HP installer malfunction.
I've found a number of similar cases, where software
installers check the IE version for no good reason.
So I set that Registry value high and recommend the
same to others.

-----------

Firefox is awkward because it doesn't register
its executable in the App Paths Registry key.
On my system it's accessible in two ways:

1)
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall\Mozil
la Firefox (1.5)\DisplayVersion

I have v. 1.5 installed. Clearly this method requires some
parsing, though. It doesn't look like a very dependable
approach. You'd have to enumerate the Uninstall keys
(probably with WMI) and check for one with "firefox"
in the name. However the InstallLocation value should
give you the FF program folder, where you could check the
file version. But that then involves another problem:
Firefox.exe has a file version that's actually the gecko
version! What you need is the "product version". For that,
see here for a VBS class that extracts the version info.
data from a file's resource table:

www.jsware.net/jsware/scripts.php5#fvinfo

2) This method might be easier, but I don't know whether
it's standardized across FF versions. On my system, at least,
there's a value:
HKEY_LOCAL_MACHINE\Software\Mozilla\Mozilla Firefox\CurrentVersion

The value there is "1.5(en-US)". So again, you'd
have to parse the value.

Whatever method you end up with, if I were you
I'd check it across versions before depending on the
script. You can't depend on standardization. And you
can't depend on program path.

Bob Barrows

unread,
Jun 15, 2009, 10:43:29 AM6/15/09
to
jharp80 wrote:
> On Jun 15, 7:09 am, "Bob Barrows" <reb01...@NOyahoo.SPAMcom> wrote:
>> jharp80 wrote:
>>> Hi I would like to detect broswer type and version (Example FF2,
>>> FF3, IE, so on) on the client side using VBScript.
>>
>> You will not be able to use vbscript with Firefox - it is not
>> supported. You
>> will need to use javascript instead.
>>
>>> I appreciate any script
>>> on this I can do; and if not available some general guidelines how I
>>> should accomplish this using VBSCript ;example what objects i need
>>> to query. or is it possible to do this through reading registry
>>> keys.
>>
>> No registry keys are needed. DHTM should suffice.
>> See:http://www.dynamicdrive.com/dynamicindex9/browsersniffer.htm
>>
>
> Thanks for your reply. I am interested in detecting only Firefox and
> IE versions installed.

Installed? That's a different question. That answer would require a
search of the registry.

> And I like to do so without the browesers
> actually launched.
>
> I have an hta script; so the code that I am looking for to do the
> detection will be included in that hta script written in VBScript.

An HTA page runs in a browser doesn't it? It just uses a different
library to process the html.

> There must be a way to detect firefox as well, the script you
> mentioned seems to support detection of several broswers but Firefox

I found that page via a google search that had many more hits, many of
which will contain the details for firefox:
http://lmgtfy.com/?q=javascript+browser+detection

--
HTH,
Bob Barrows


jharp80

unread,
Jun 15, 2009, 3:12:30 PM6/15/09
to
Thanks for your reply. So It sounds like I need to embed some vbscript
code reading registry keys to fetch the browser information.

Al Dunbar

unread,
Jun 16, 2009, 1:22:09 AM6/16/09
to

"mayayana" <mayaX...@rcXXn.com> wrote in message
news:eZRvwib7...@TK2MSFTNGP02.phx.gbl...

mayayana

unread,
Jun 16, 2009, 8:59:50 AM6/16/09
to
My goodness, Al, we seem to have rendered
you speechless. :)

--
--
Al Dunbar <alan...@hotmail.com> wrote in message
news:uQH5nJk7...@TK2MSFTNGP02.phx.gbl...

Al Dunbar

unread,
Jun 17, 2009, 12:34:15 AM6/17/09
to

"mayayana" <mayaX...@rcXXn.com> wrote in message
news:eVSDqKo7...@TK2MSFTNGP06.phx.gbl...

> My goodness, Al, we seem to have rendered
> you speechless. :)

LOL. But not you guys. I have switched to the Windows Live Mail Client and
often post null replies. When I click on the reply-group button, the mouse
pointer is left hovering over the send button, and I inadvertently tap the
touchpad on this laptop, or hit the left button.


/Al

Mark D. MacLachlan

unread,
Jul 1, 2009, 12:56:53 PM7/1/09
to
jharp80 wrote:

I had to grab FireFox versions a little while back myself. THis is the
solution I came up with:

[code]
'=======================================================================
===
'
' NAME: GetFireFoxVersion.vbs
'
' AUTHOR: Mark D. MacLachlan , The Spider's Parlor
' URL: http://www.thespidersparlor.com
' DATE : 1/27/2009
' COPYRIGHT © 2009, All Rights Reserved
'
' COMMENT:
' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
' ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED To
' THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
' PARTICULAR PURPOSE.
'
' IN NO EVENT SHALL THE SPIDER'S PARLOR AND/OR ITS RESPECTIVE
SUPPLIERS
' BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
' DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
' WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
' ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
' OF THIS CODE OR INFORMATION.
'
'=======================================================================
===
Dim objFSO
strComputer = "."

Set objFSO = CreateObject("Scripting.FileSystemObject")

If objFSO.FileExists("C:\Program Files (x86)\Mozilla
Firefox\FireFox.exe") Then
FF = "C:\\Program Files (x86)\\Mozilla Firefox\\FireFox.exe"
ElseIf objFSO.FileExists("C:\Program Files\Mozilla
Firefox\FireFox.exe") Then
FF = "C:\\Program Files\\Mozilla Firefox\\FireFox.exe"
Else
FF = "NotFound" 'FireFox not found
End If

If FF <> "NotFound" Then
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer &
"\root\cimv2")
Set colFiles = objWMIService.ExecQuery _
("Select * from CIM_Datafile Where name = '" & FF &"'")
For Each objFile in colFiles
Wscript.Echo "FireFox Version: " & objFile.Version
Next
End If
[/code]

--

Mark D. MacLachlan

unread,
Jul 1, 2009, 1:23:25 PM7/1/09
to
Bob Barrows wrote:

Actually an HTA does not run in a browser, it runs in the process
MSHTA.EXE. It is independent of IE or FireFox.

Regards,

Mark D. MacLachlan

--

Bob Barrows

unread,
Jul 1, 2009, 1:44:41 PM7/1/09
to
Mark D. MacLachlan wrote:

> Bob Barrows wrote:
>> An HTA page runs in a browser doesn't it? It just uses a different
>> library to process the html.
>>
> Actually an HTA does not run in a browser, it runs in the process
> MSHTA.EXE. It is independent of IE or FireFox.
>
I stand corrected. Thanks

--
Bob Barrows


mayayana

unread,
Jul 1, 2009, 5:59:27 PM7/1/09
to

> Actually an HTA does not run in a browser, it runs in the process
> MSHTA.EXE. It is independent of IE or FireFox.
>

For all practical purposes it is IE, with a handful of
minor differences connected with MSHTA.exe, and an
extra <HTA tag that mshta processes.
If you look at the window hierarchy you'll see that
under the mshta window is a window of class
Internet Explorer_Server. That's an IE browser window.
It's the window class that an IE webpage runs in,
whether it's IE, a WebBrowser control, an HTA, or even
a pre-XP Active Desktop folder window. They're all
basically IE. The difference is only in the "chrome" or
parent window frame.


mayayana

unread,
Jul 1, 2009, 6:04:27 PM7/1/09
to

That method seems a bit iffy.
You're assuming that FF is in Program Files and
that the folder is the default. I happen to use simply
"Firefox" as the parent folder, which is an easy
choice to make during install. Likewise, someone
might easily not install to P.F. In fact, avoiding the
PF folder has been a favorite trick of people struggling
with UAC under Vista.

mayayana

unread,
Jul 2, 2009, 12:24:35 AM7/2/09
to
>>' NAME: GetFireFoxVersion.vbs
>>'
>>' AUTHOR: Mark D. MacLachlan , The Spider's Parlor
>>' URL: http://www.thespidersparlor.com
>>' DATE : 1/27/2009
>>' COPYRIGHT � 2009, All Rights Reserved
>>'

> > If FF <> "NotFound" Then


> > Set objWMIService = GetObject("winmgmts:" _
> > & "{impersonationLevel=impersonate}!\\" & strComputer &
> > "\root\cimv2")
> > Set colFiles = objWMIService.ExecQuery _
> > ("Select * from CIM_Datafile Where name = '" & FF &"'")
> > For Each objFile in colFiles
> > Wscript.Echo "FireFox Version: " & objFile.Version
> > Next

Also note, if you had read the rest of the
thread you'd know that there's another glitch
with this method. Using a simplified version
of your script:

Set objFile = GetObject("winmgmts:CIM_Datafile.Name='C:\program
files\firefox\firefox.exe'")
MsgBox objFile.Version

I have FF 1.5 installed. It returns v. 1.8. That's
because the FF file version is actually the gecko
version. The real file version is the product version.
There's a cross-reference chart here:

http://en.wikipedia.org/wiki/Gecko_(layout_engine)

One has to wonder why you took the trouble
to post such an off-the-cuff response to a thread
that's been closed for two weeks, and without even
reading the oher posts, unless it's just to spam the
group with your ad for a $150 package of scripts.

Incidentally, I'm not claiming any copyright on
my two lines of script posted above. You can have
them both for a one-time-only-special-price of *free*. :)


Mark D. MacLachlan

unread,
Jul 2, 2009, 4:52:53 PM7/2/09
to
Mayayana, I didn't realize it was considered bad form to try to provide
additional methods to a problem. I've just started using these forums
at the recommendation of a coworker. I've provided free technical
support on the Tek-Tips web site for years, having posted over 10K
replies and been an MVP on that site for many years.

I guess the biggest difference between the sites is that Tek-Tips
management has a no flame policy. Your post is an unprovoked personal
attack.

Why you should care that I add copyright and disclaimer information to
a script I have given for free is beyond my comprehension. I believe
credit should be given where due as evidenced in my login script FAQ
http://www.tek-tips.com/faqs.cfm?fid=5798 where I site others who
contributed some functions.

For the record I did read the entire threads and believed that
information provided for IE was sufficient but I felt I could
contribute to the discussion on FireFox.

Good day to you.

Mark

0 new messages