Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get windows 10 build version (release ID)

I want to get Windows build version. I have searched everywhere for this, but to no avail.

No, I don't want to know if it's 7, 8, 10, or whatever. I don't want the Windows build number. I want to know the Windows build version (1507, 1511, 1607, etc.)

I am not sure what the official name of this would be, but here is an image of what I'm asking for:

enter image description here

I tried using the sys, os and platform modules, but I can't seem to find anything built-in that can do this.

like image 805
Božo Stojković Avatar asked Aug 13 '16 18:08

Božo Stojković


2 Answers

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
like image 98
napuzba Avatar answered Nov 17 '22 20:11

napuzba


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 
like image 3
Gringo Suave Avatar answered Nov 17 '22 19:11

Gringo Suave