469,568 Members | 1,547 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,568 developers. It's quick & easy.

Detect and Display Windows Version

Please help. Looking for a script to detect and display what version of
Windows a user is running.

Thanks in advance.
Rich
Nov 28 '05 #1
9 11357
Ri**@nospam.com said the following on 11/28/2005 1:23 PM:
Please help. Looking for a script to detect and display what version of
Windows a user is running.


When you find it, can you post back the results it gives when executed
on a MAC or a Linux based system?

But, stop looking as trying to figure out what you are trying to figure
out goes outside the security boundaries of the browser.

But, if your users need you to tell them the OS, they don't need a
computer.....

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Nov 28 '05 #2
The scipt is for an intranet site. We only have Win OS machines so MAC and
Linux is not an issue. What I am trying to do is show the user their OS,
version of Media Player and Browser version. I am able to do the last 2 but
can't figure out how to show the OS.
Nov 28 '05 #3
VK

Ri**@nospam.com wrote:
The scipt is for an intranet site. We only have Win OS machines so MAC and
Linux is not an issue. What I am trying to do is show the user their OS,
version of Media Player and Browser version. I am able to do the last 2 but
can't figure out how to show the OS.


You cannot do it directly from the available browser info, because in
userAgent string (and other places) Microsoft uses version codes (5.0,
5.1 etc) and not the market names like Windows ME, Windows XP etc.

So you have to make (or find) a match table {version code : marken
name}, study navigator.userAgent for code and display the match from
that table.

This is the only way I can think of.

Nov 28 '05 #4
Ri**@nospam.com wrote:
Please help. Looking for a script to detect and display what version of
Windows a user is running.

Thanks in advance.
Rich
There's a place called the Microsoft Developer Network (MSDN) that you
can search for such things.

You can look at the platform property of the navigator object, or you
can try the clientInformation object (they seem identical for all
practical purposes). All you will get for the platform is 'Win32' which
is probably anything from Windows 95 onward (or maybe even Windows 3.1
with the 32-bit stuff added, I dunno) and note that users can likely
spoof that if they want.

The properties of both objects are shown in IE by the following ( -
Mozilla/Gecko does not support the clientInformation object):

<script type="text/javascript">

var HTMLstring = '';
if ('object' == typeof navigator){
HTMLstring += '<h1>Navigator properties</h1>';
for (var prop in navigator){
HTMLstring += '<b>' + prop + '</b>: ' + navigator[prop] + '<br>';
}
}
if ('object' == typeof clientInformation){
HTMLstring += '<h1>clientInformation properties</h1>';
for (prop in clientInformation){
HTMLstring += '<b>' + prop + '</b>: ' + clientInformation[prop] +
'<br>';
}
}
document.write(HTMLstring);

</script>


Navigator object:
<URL:
http://msdn.microsoft.com/workshop/a..._navigator.asp
clientInformation object:
<URL:
http://msdn.microsoft.com/workshop/a...nformation.asp

--
Rob
Nov 28 '05 #5
A while ago I found a script that was able to redirect a user based on the
version OS. At the time I only needed to detect NT4 vs Win2k/XP. Here is
the script:

<script>
var n = navigator;
var ua = ' ' + n.userAgent.toLowerCase();

// find windows platform

var is_win = ua.indexOf('win') > 0;
var is_winnt4 = (ua.indexOf('nt 4.0') > 0 && ua.indexOf('win') > 0);

if(is_winnt4){document.location = "wm_player_framesetnt.html"}
else {document.location = "wm_player_framesetxp.html"}
</script>

This is why I thought it was possible to also detect Win2k vs XP.
Nov 29 '05 #6
Ri**@nospam.com wrote:
A while ago I found a script that was able to redirect a user based on the
version OS. At the time I only needed to detect NT4 vs Win2k/XP. Here is
the script:

<script>
var n = navigator;
var ua = ' ' + n.userAgent.toLowerCase();

// find windows platform

var is_win = ua.indexOf('win') > 0;
var is_winnt4 = (ua.indexOf('nt 4.0') > 0 && ua.indexOf('win') > 0);

if(is_winnt4){document.location = "wm_player_framesetnt.html"}
else {document.location = "wm_player_framesetxp.html"}
</script>

This is why I thought it was possible to also detect Win2k vs XP.


The user agent string for IE on the machine that I'm using at the moment
comes up as:

Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)

You work it out[1]. :-)

I think as VK says, you need to reverse engineer it. Every time you get
a user agent string you can't decipher or haven't come across before,
visit the machine, find out what it's running and add it to your
user-agent-deciphering routine.

But it will only work if you can control what the UA string is (the sys
admins at some places I work do, but not all). How do you know someone
isn't running some other browser/UA and putting whatever in the UA string?
1. XP Pro SP 1
--
Rob
Nov 29 '05 #7
RobG said the following on 11/28/2005 10:08 PM:
Ri**@nospam.com wrote:
A while ago I found a script that was able to redirect a user based on
the
version OS. At the time I only needed to detect NT4 vs Win2k/XP.
Here is
the script:

<script>
var n = navigator;
var ua = ' ' + n.userAgent.toLowerCase();

// find windows platform

var is_win = ua.indexOf('win') > 0;
var is_winnt4 = (ua.indexOf('nt 4.0') > 0 && ua.indexOf('win') > 0);

if(is_winnt4){document.location = "wm_player_framesetnt.html"}
else {document.location = "wm_player_framesetxp.html"}
</script>

This is why I thought it was possible to also detect Win2k vs XP.

The user agent string for IE on the machine that I'm using at the moment
comes up as:

Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)

You work it out[1]. :-)

I think as VK says, you need to reverse engineer it. Every time you get
a user agent string you can't decipher or haven't come across before,
visit the machine, find out what it's running and add it to your
user-agent-deciphering routine.

But it will only work if you can control what the UA string is (the sys
admins at some places I work do, but not all). How do you know someone
isn't running some other browser/UA and putting whatever in the UA string?
1. XP Pro SP 1


Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR
1.1.4322; .NET CLR 2.0.50727)

Windows XP Home SP2

It will be interesting to see how people differentiate XP Pro from XP
Home from the UA string :)

I still say you can't reliably get the OS from the browser. Keyword
being reliably.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Nov 29 '05 #8
Randy Webb wrote:
RobG said the following on 11/28/2005 10:08 PM: [...]
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR
1.1.4322; .NET CLR 2.0.50727)

Windows XP Home SP2
How about:

Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)

Windows 2000 Pro SP 4 (no .NET framework - I have no use for it - hence
on CLR stuff I guess).

It will be interesting to see how people differentiate XP Pro from XP
Home from the UA string :)

I still say you can't reliably get the OS from the browser. Keyword
being reliably.


No argument with that.
--
Rob
Nov 29 '05 #9
VK

VK wrote:
You cannot do it directly from the available browser info, because in
userAgent string (and other places) Microsoft uses version codes (5.0,
5.1 etc) and not the market names like Windows ME, Windows XP etc.

So you have to make (or find) a match table {version code : marken
name}, study navigator.userAgent for code and display the match from
that table.


And these Microsoft tables will help you:
<http://msdn.microsoft.com/workshop/author/dhtml/overview/aboutuseragent.asp#UARegistry>

Nov 30 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Etienne Charland | last post: by
23 posts views Thread by David McCulloch | last post: by
1 post views Thread by Kevin | last post: by
6 posts views Thread by Fred Hedges | last post: by
reply views Thread by suresh191 | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.