Windows 10 Version and Buil Number with VB.Net

~OSD~ 2,126 Reputation points
2021-05-06T07:51:43.973+00:00

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,580 questions
0 comments No comments
{count} votes

Accepted answer
  1. Leon Laude 85,666 Reputation points
    2021-05-06T08:21:07.047+00:00

    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,126 Reputation points
    2021-05-06T08:26:42.733+00:00

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


  2. ~OSD~ 2,126 Reputation points
    2021-05-06T09:54:55.823+00:00

    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
    2023-03-28T20:57:55.35+00:00

    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