2

I am using VB .Net 2.0. I know I can detect the OS using

System.Environment.OSVersion

Can anyone tell me if there's a list somewhere where I can find what that generates for different OS versions.

Specifically I am trying to detect if a user is running Windows 7 64-bit.

EndangeredMassa
  • 17,208
  • 8
  • 55
  • 79
Tim
  • 25
  • 1
  • 5

5 Answers5

0

This worked for me, Instead of checking the version numbers , this just checks the text that is returned by the Windows OS

GET the OPERATING SYSTEM NAME

        Dim machineOSPlatform as String
        If My.Computer.Info.OSFullName.Contains("7") Then
            machineOSPlatform = "Windows 7"
        ElseIf My.Computer.Info.OSFullName.Contains("XP") Then
            machineOSPlatform = "Windows XP"
        ElseIf My.Computer.Info.OSFullName.Contains("8") Then
            machineOSPlatform = "Windows 8"
        ElseIf My.Computer.Info.OSFullName.Contains("Vista") Then
            machineOSPlatform = "Windows Vista"
        ElseIf My.Computer.Info.OSFullName.Contains("2008") Then
            machineOSPlatform = "Windows 2008 Server"
        ElseIf My.Computer.Info.OSFullName.Contains("2012") Then
            machineOSPlatform = "Windows 2012 Server"
        ElseIf My.Computer.Info.OSFullName.Contains("2003") Then
            machineOSPlatform - "Windows 2003 Server"
        Else
            machineOSPlatform = "Unknown OS"
        End If

http://www.vbforums.com/showthread.php?676340-how-can-i-get-visual-basic-to-show-what-os-your-running

0

Use:

Environment.OSVersion.ToString()

This will return values like:

"Microsoft Windows NT 5.0.2195.0"

Here is a link on how to extract the OS from the version/build numbers.

Or you can use this function:

Public Function GetOSVersion() As String
    Select Case Environment.OSVersion.Platform
        Case PlatformID.Win32S
            Return "Win 3.1"
        Case PlatformID.Win32Windows
            Select Case Environment.OSVersion.Version.Minor
                Case 0
                    Return "Win95"
                Case 10
                    Return "Win98"
                Case 90
                    Return "WinME"
                Case Else
                    Return "Unknown"
            End Select
        Case PlatformID.Win32NT
            Select Case Environment.OSVersion.Version.Major
                Case 3
                    Return "NT 3.51"
                Case 4
                    Return "NT 4.0"
                Case 5
                    Select Case _
                        Environment.OSVersion.Version.Minor
                        Case 0
                            Return "Win2000"
                        Case 1
                            Return "WinXP"
                        Case 2
                            Return "Win2003"
                    End Select
                Case 6
                    Return "Vista/Win2008Server"
                Case Else
                    Return "Unknown"
            End Select
        Case PlatformID.WinCE
            Return "Win CE"
    End Select
End Function
Community
  • 1
  • 1
Tom Gullen
  • 61,249
  • 84
  • 283
  • 456
0

For a list of versions see here: http://www.nirmaltv.com/2009/08/17/windows-os-version-numbers/

To find out 32 vs 64 bit, see this previous question: How to detect Windows 64-bit platform with .NET?

Community
  • 1
  • 1
Hans Olsson
  • 54,199
  • 15
  • 94
  • 116
0

The most comprehensive solution for this I've found is PJ Naughter's DtWinver class. It can distinguish between editions of Windows (Starter Edition, Home Basic, Home Premium, Professional, Enterprise, etc.), which admittedly might be functionality you don't need.

jeffm
  • 3,120
  • 1
  • 34
  • 57