Search code examples
c#.netwindows-10

C# - How to show the full Windows 10 build number?


How to show the full Windows 10 build on C#?

I'm currently using Environment.OSVersion.VersionString but it's not showing the full build number

The result:

Microsoft Windows NT 10.0.17134.0

But I want the last number, my full build: 10.0.17134.228

I want to know how can I show the last missing number. Not only where to find the number. The c# code to get it.


Solution

  • The Windows 10 build number is stored in the registry in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ in the UBR key.

    Here's how to get it in code:

    using Microsoft.Win32;
    
    // ...
    
    RegistryKey registryKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion");
    
    var buildNumber = registryKey.GetValue("UBR").ToString();
    

    EDIT: Fixed the value name to get the correct number for OP. Credit for the correct key to Jorge Aguiar.