Is there an *official* way to detect Windows 11?

Viewed 1672

The following question contains various ways to detect whether a system is running Windows 10 or Windows 11:

However, they all seem a bit "hackish" and brittle: checking file versions, build numbers, API availability, etc. Since the release of Windows 11 is just around the corner (ETA Oct 5), software vendors don't have much time left to prepare. Hence my question:

Has Microsoft published an officially recommended way for software developers to check for Windows 11, if you have a legitimate reason¹ for needing to know?


¹ I am aware that many programs think they need to check the OS version number, when, in fact, they should only be concerned about the availability of the specific feature they need. I fully support that. However, there are legitimate use cases (for example, a system management or software inventory tool), and I'd ask you to assume a legitimate use case for the purpose of this question.

PS: This question is deliberately not constrained to a particular technology; I consider any officially supported solution (using WinAPI, WMI, COM, .NET, ...) a valid answer.

5 Answers

The question thread "Windows 11 build ver is still 10.0.22000.194" on Microsoft Q&A has received responses from two Microsoft employees. In the accepted answer, one says:

At least for now, OS build number 22000 is the standard that distinguishes Windows 10 from Windows 11.

And, in a comment below the answer, another adds:

This is correct. Anything above 10.0.22000.0 is Win 11. Anything below is Win 10.

This suggests that, at the time of that writing, a week after the public release of Windows 11, Microsoft had not yet published an official recommendation for software developers. That may obviously change at some point, but until then the 22000 build number seems to be the criterion one should rely on to draw the line between Windows 10 and 11.

Windows 11's architecture still basically uses Windows 10. There are plenty of leftover files and systems from Windows 10. Plenty of occurrences happened such as misnamed update names. Windows 11 still uses the Windows 10 version number as well. Now while command prompt is obsolete, it's still a core system of all Windows Systems. So I made a little something that can detect it using systeminfo (slow, ik)

From: https://www.lifewire.com/windows-version-numbers-2625171

systeminfo | findstr /i /c:"windows 11" > nul && {code here for windows 11} || {code here for not windows 11}

I know it may not be the solution you're looking for, and it's hard to implement batch script onto a modern app, but happy to help!

How about this one-liner for dos? Powershell would be even easier.

FOR /F "tokens=1,2,3 delims= " %%A IN ('wmic os get Caption') DO IF %%B EQU Windows set WVer=%%B %%C

This will return "Windows 10" or "Windows 11"

If you want the full version, for example: PRO/Education etc then you can expand it.

FOR /F "tokens=1,2,3,4 delims= " %%A IN ('wmic os get Caption') DO IF %%B EQU Windows set WVer=%%B %%C %%D

Cheers

Maybe we can use the following code:

auto fnWindows11OrGreater = []() -> bool {
    OSVERSIONINFOEX osvi;
    ZeroMemory(&osvi, sizeof(OSVERSIONINFO));
    osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
    osvi.dwMajorVersion = 10;
    osvi.dwMinorVersion = 0;
    osvi.dwBuildNumber = 22000;
    DWORDLONG dwlConditionMask = 0;
    VER_SET_CONDITION(dwlConditionMask, VER_MAJORVERSION, VER_EQUAL);
    VER_SET_CONDITION(dwlConditionMask, VER_MINORVERSION, VER_EQUAL);
    VER_SET_CONDITION(dwlConditionMask, VER_BUILDNUMBER, VER_GREATER_EQUAL);
    bool cond1 = VerifyVersionInfo(&osvi, VER_MAJORVERSION | VER_MINORVERSION | VER_BUILDNUMBER, dwlConditionMask);

    ZeroMemory(&osvi, sizeof(OSVERSIONINFO));
    osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
    osvi.dwMajorVersion = 10;
    osvi.dwMinorVersion = 0;
    osvi.dwBuildNumber = 0;
    dwlConditionMask = 0;
    VER_SET_CONDITION(dwlConditionMask, VER_MAJORVERSION, VER_EQUAL);
    VER_SET_CONDITION(dwlConditionMask, VER_MINORVERSION, VER_GREATER);
    VER_SET_CONDITION(dwlConditionMask, VER_BUILDNUMBER, VER_GREATER_EQUAL);
    bool cond2 = VerifyVersionInfo(&osvi, VER_MAJORVERSION | VER_MINORVERSION | VER_BUILDNUMBER, dwlConditionMask);

    ZeroMemory(&osvi, sizeof(OSVERSIONINFO));
    osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
    osvi.dwMajorVersion = 10;
    osvi.dwMinorVersion = 0;
    osvi.dwBuildNumber = 0;
    dwlConditionMask = 0;
    VER_SET_CONDITION(dwlConditionMask, VER_MAJORVERSION, VER_GREATER);
    VER_SET_CONDITION(dwlConditionMask, VER_MINORVERSION, VER_GREATER_EQUAL);
    VER_SET_CONDITION(dwlConditionMask, VER_BUILDNUMBER, VER_GREATER_EQUAL);
    bool cond3 = VerifyVersionInfo(&osvi, VER_MAJORVERSION | VER_MINORVERSION | VER_BUILDNUMBER, dwlConditionMask);

    return cond1 || cond2  || cond3;
};
Related