OSVersion Property

Type: String

OSVersion returns the version of the installed operating system. Possible return values include "9.2.2", "10.1", "10.3.9", "10.4", "10.4.2" (in the case of a MacOS), "4.0", "4.1", "4.9", "5.0", "5.1", "5.2", and "6.0" (in the case of Windows) and other values with other operating systems.

 

Details on the possible return results follow:

 

Mac OS: Specific for Mac OS, the following table can be used to translate the Mac OS version to the corresponding Mac OS product name:

OSVersion Product Name

"9.0"  Mac OS 9

"10.0"  Cheetah

"10.1"  Puma

"10.2"  Jaguar

"10.3"  Panther

"10.4"  Tiger

'10.5"  Leopard

 

Note: Results typically include a "dot release" in the version. For example "10.4", or "10.4.1" or "10.4.2". Therefore make sure your string comparisons take this into account. For example do not use OSVersion = "10.4" since that will not return true for any 10.4.x subversion returned. Use the CompareVersions method to make it easy to check for a minimum version number you require.

 

Windows: The following table can be used to translate the OSVersion to a Windows product name for Windows based operating systems. Note that the OSName property returns these results for you.

OSVersion Product Name

"4.0"  Windows 95

"4.1"  Windows 98

"4.9"  Windows ME

"5.0"  Windows 2000

"5.0 build 0" Windows CE

"5.1"  Windows XP

"5.2"  Windows 2003 Server

"6.0"  Windows Vista

 

Special notes for this property:

 

Note: You must call the GetExtPropertiesEx method before checking the value of this property. This property requires the Enterprise Edition of BrowserHawk.

 

Example 1 - General Demonstration:

This example shows how to get the OSName and OSVersion properties, and displays the results for demonstration purposes:

<% set bhObj = Server.CreateObject("cyScape.browserObj")

bhObj.SetExtProperties "OSName, OSVersion"

bhObj.GetExtPropertiesEx

%>

<html>

<%

if bhObj.OSName = -1 OR bhObj.OSName = -2 then

'Fall back to use the Platform property when OSName is not available

Response.Write "OSName: Not available"

Response.Write " (Platform property is " & bhObj.Platform & ") <p>"

else

Response.Write "OSName: " & bhObj.OSName & "<p>"

end if

 

if bhObj.OSVersion = -1 OR bhObj.OSVersion = -2 then

Response.Write "OSVersion: Not available"

else

Response.Write "OSVersion: " & bhObj.OSVersion & "<p>"

end if

%>

</html>

 

Example 2 - Detecting Mac OS version:

This example shows how to use the OSName and OSVersion properties to check for Mac OS X version 10.4.2 or higher. For purposes of this example, any Mac users with a version prior to 10.4.2 is redirected to another page.

<% set bhObj = Server.CreateObject("cyScape.browserObj")

'First check to see if they are even on a Mac.

'If not we can bypass these tests so that non-Mac users (Windows users

'for example) are not even tested for OSName and OSVersion which

'maximizes the efficiency of our code.

if left(bhObj.Platform, 3) = "Mac" then

'They are using a Mac, so get the specific Mac OS version number

bhObj.SetExtProperties "OSVersion"

bhObj.GetExtPropertiesEx

osver = bhObj.OSVersion

if osver = "-1" OR osver = "-2" then

' result of OSVersion is unavailable - handle this situation as you wish

else

' Check to see if they have Mac OS X 10.4.2 or higher.

' We use the CompareVersions method to check the version number

' since it makes numeric comparisons with strings very easy.

if bhObj.CompareVersions(osver, "10.4.2") < 0 then

' user has Mac OS prior to OS X 10.4.2, redirect them to another page

response.redirect "/old_mac_users.asp"

end if

end if

end if

%>

<html> Page for all users except those with Mac OS prior to 10.4.2 goes here </html>

 

See Also:

Additional Steps Required for Java based properties

Detecting Operating System Details

OSArch Property

OSName Property

Platform Property

CompareVersions Method