Get windows 10 build version (release ID)

It seems you are looking for the ReleaseID which is different from the build number.

You can find it by query the value of ReleaseID in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion registry key.

You can query the value using winreg module:

import winreg

def getReleaseId():    
    key = r"SOFTWARE\Microsoft\Windows NT\CurrentVersion"
    val = r"ReleaseID"

    with winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, key) as key:
        releaseId = int(winreg.QueryValueEx(key,val)[0])

    return releaseId

or REG command:

import os

def getReleaseId():
    key = r"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion"
    val = r"ReleaseID"

    output = os.popen( 'REG QUERY "{0}" /V "{1}"'.format( key , val)  ).read()
    releaseId = int( output.strip().split(' ')[-1] )

    return releaseId

The build number is sufficient and can be found with:

sys.getwindowsversion().build

or the platform module. Match the build with the table at this link to determine the ReleaseId you'd like to target:

  • https://en.m.wikipedia.org/wiki/Windows_10_version_history

In this case 1511 corresponds to TH2 and build 10586:

# 1511  Threshold 2     November 10, 2015   10586 

You can use ctypes and GetVersionEx from Kernel32.dll to find the build number.

import ctypes
def getWindowsBuild():   
    class OSVersionInfo(ctypes.Structure):
        _fields_ = [
            ("dwOSVersionInfoSize" , ctypes.c_int),
            ("dwMajorVersion"      , ctypes.c_int),
            ("dwMinorVersion"      , ctypes.c_int),
            ("dwBuildNumber"       , ctypes.c_int),
            ("dwPlatformId"        , ctypes.c_int),
            ("szCSDVersion"        , ctypes.c_char*128)];
    GetVersionEx = getattr( ctypes.windll.kernel32 , "GetVersionExA")
    version  = OSVersionInfo()
    version.dwOSVersionInfoSize = ctypes.sizeof(OSVersionInfo)
    GetVersionEx( ctypes.byref(version) )    
    return version.dwBuildNumber