title: How to identify OS in VB.Net using build number
body: <p>I have an existing application that uses  System.Environment.OSVersion.Version.Major to identify the operating system the application is running on. I use this to make sure the application is not being run on an unsupported operating system. </p>
  
  <p>I have currently hit a snag in that I need to be able to identify if the user is using Vista with no SP, Vista SP1, Vista SP2, Windows 7, Windows 7 SP1, Server 2008, Server 2008 R2, Windows 8 and Windows 8 SP1 as some settings in the application depend upon the Service Pack Version. </p>
  
  <p>From what I have looked up Windows 7 and server 2008 share the same build numbers so this is a problem likewise the way Microsoft did version numbering on the minor would cause my current code to not work as expected. </p>
  
  <p>Build numbers </p>
  
  <pre><code>Vista                       6.0.6000 
  Vista SP1 ????????          6.0.6001.18000
  Vista SP2                   6.0.6002
  Windows Server 2008         6.0.6001
  Windows 7                   6.1.7600
  Windows 7 SP1               6.1.7601
  Windows Server 2008 R2      6.1.7600
  Windows Server 2008 R2 SP1 ???  6.0.7601
  </code></pre>
  
  <p>Is their a better way to do this or an extended functionality to the System.Environment.Version to use the build number? I have spent hours searching for answers to no avail.  </p>
  
  <p>My current code is below</p>
  
  <pre><code>  Select Case System.Environment.OSVersion.Version.Major
          Case 5
              Select Case _
                  System.Environment.OSVersion.Version.Minor
                  Case 0
                      Dim frm As New Win2000
                      frm.Show(Win2000)
                  Case 1
                      Dim frm As New XP
                      frm.Show(XP)
                  Case 2
                      Dim frm As New Win2003
                      frm.Show(Win2003)
                  Case Else
                      Dim frm As New Unsupported
                      frm.Show(Unsupported)
              End Select
          Case 6
              Select Case _
                  System.Environment.OSVersion.Version.Minor
                  Case 0
                      If My.Computer.Info.OSFullName.Contains("Home Basic") Then
                          Dim frm As New VistaHB
                          frm.Show(VistaHB)
                      End If
                      If My.Computer.Info.OSFullName.Contains("Home Premium") Then
  
                          Dim frm As New VistaPre
                          frm.Show(VistaPre)
                      End If
                      If My.Computer.Info.OSFullName.Contains("Ultimate") Then
  
                          Dim frm As New VistaUlt
                          frm.Show(VistaUlt)
                      End If
                      If My.Computer.Info.OSFullName.Contains("Business") Then
                          Dim frm As New VistaB
                          frm.Show(VistaB)
                      End If
                  Case 1
                      If My.Computer.Info.OSFullName.Contains("Home Basic") Then
                          Dim frm As New Win7HB
                          frm.Show(Win7HB)
                      End If
                      If My.Computer.Info.OSFullName.Contains("Home Premium") Then
  
                          Dim frm As New Win7Pre
                          frm.Show(Win7Pre)
                      End If
                      If My.Computer.Info.OSFullName.Contains("Ultimate") Then
  
                          Dim frm As New Win7Ult
                          frm.Show(Win7Ult)
                      End If
                      If My.Computer.Info.OSFullName.Contains("Business") Then
                          Dim frm As New Win7biz
                          frm.Show(Win7biz)
                      End If
  
                  Case Else
                      Dim frm As New Unsupported
                      frm.Show(Unsupported)
              End Select
      End Select
  </code></pre>