How can I find the Windows product name in Windows 11?

  .net, .net-core, c++, windows, windows-11

Windows 11, released yesterday, reports itself as Windows 10.0 just about everywhere – RtlGetVersion says 10.0, and if you ask VerifyVersionInfo if you are 11.0 or greater, it says no.

There seems to be no new GUID to shove into app.manifest to say "hey I support Windows 11" like there was for Windows 7, 8, 8.1, and 10.

Currently I rely on HKLM:SOFTWAREMicrosoftWindows NTCurrentVersionProductName to tell me what the current version of Windows is, but on my machine that I’ve upgraded, it still says "Windows 10 Enterprise", not "Windows 11 Enterprise".

There appears to only be a single place in the registry that contains the text "Windows 11" and that is the BCD section (boot configuration), which can also be renamed so I don’t want to touch that.

So far I have only identified a handful of methods to tell if I am running on Windows 11:

  1. Invoke WMI to query Win32_OperatingSystem and check the Name property, which simply says "Windows 11". This is incomplete (it does not include the SKU such as "Enterprise"), and WMI is relatively slow and slightly brittle, so it’s not an acceptable solution for my use-case.

  2. Check the build number to see if it is above 21996 (beta builds) or 22000 (first public release). As above, this won’t include the SKU, and would require some manual jiggery-pokery in order to build the full string.

  3. Run sysinfo and parse the output. This is quite slow, and possibly brittle (I haven’t checked but the output might be localised into different languages).

  4. winver knows, but it’s a GUI application so I can’t exactly query it programmatically.

Does anyone have any other ideas on how to get the string "Windows 11 Enterprise" (or "Windows 11 Pro", etc. as the case may be) out of my operating system in a performant and complete manner? Where do WMI, sysinfo, and winver get it from?

I need to do this from a .NET library, but P/Invokes / native function calls are acceptable solutions.

Source: Windows Questions