Share via

Windows 10 Version and Buil Number with VB.Net

~OSD~ 2,201 Reputation points
May 6, 2021, 7:51 AM

Hi,

I would like to get Windows Version (let's say 202H) and OS build (like 19042.928), as highlighted in below screenshot.
94332-image.png

Using Win32_OperatingSystem in VB.Net as ("root\CIMV2", "SELECT * FROM Win32_OperatingSystem")
And I am able to get partial build number 19042 using "BuildNumber" property of the Win32_OperatingSystem class ( win32-operatingsystem) However, I not able to figure out how to get:

  1. The remaining part of the build number (928 in this example).
  2. The Windows version like 20H2 (highlighted in green color in the screenshot).
VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,827 questions
0 comments No comments
{count} votes

Accepted answer
  1. Leon Laude 85,996 Reputation points
    May 6, 2021, 8:21 AM

    Hi @~OSD~ ,

    The Win32_OperatingSystem class can only retrieve the BuildNumber which is 19042 in your case, the last three (3) digits is the revision number of the build, to retrieve the revision number I believe you will have to query the Windows Registry.

    ----------

    (If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)

    Best regards,
    Leon

    1 person found this answer helpful.
    0 comments No comments

3 additional answers

Sort by: Most helpful
  1. ~OSD~ 2,201 Reputation points
    May 6, 2021, 8:26 AM

    Will check that Leon.
    And how about the Version 20H2? Is it not supported as well?


  2. ~OSD~ 2,201 Reputation points
    May 6, 2021, 9:54 AM

    Great, I can get "DisplayVersion" now from Registry.
    However, in this hive, there is no such value like revisionID, I only have releaseID which is not same as last three numbers ....


  3. Pierre Rondeau 0 Reputation points
    Mar 28, 2023, 8:57 PM

    To get Windows version, you must get it from the registry.

    LabelVersion.text = My.Computer.Registry.GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "DisplayVersion", Nothing)

    For the Build : you need to put together the CurrentBuild and the SystemRoot like such

    LabelBuild.text = My.Computer.Registry.GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "CurrentBuild", Nothing) & "." & My.Computer.Registry.GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "UBR", Nothing)

    Enjoy!

    Pete

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.