shirou / gopsutil

psutil for golang
Other
10.56k stars 1.58k forks source link

Windows 11 "misreported" as Windows 10 #1143

Closed elmeyer closed 3 years ago

elmeyer commented 3 years ago

Describe the bug host.PlatformInformationWithContext returns platform = "Microsoft Windows 10 Pro" on a fresh RTM Windows 11 install (HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\BuildLabEx is 22000.1.amd64fre.co_release.210604-1628, HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProductName is "Windows 10 Pro", HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\CurrentBuildNumber is 22000).

To Reproduce Let me know if you need code for this.

Expected behavior To be honest, I am not sure how to proceed in this case, as nothing is really wrong with the way gopsutil obtains the platform information. It's just that Microsoft (probably for compatibility reasons) didn't bother to update the value of ProductName. My point with this issue is to raise the question whether or not to stick with the current behavior and take the value of ProductName as the single source of truth, or to also read CurrentBuildNumber and report Windows 11 if CurrentBuildNumber >= 22000.

I would be happy to provide a PR in the latter case.

Environment (please complete the following information):

shirou commented 3 years ago

From googling, 1, 2, 3, and some of my friends PCs, using CurrentBuildNumber is only way to detect Windows 11. so I agree to implement CurrentBuildNumber >= 22000. We will be very appreciated if you made a PR.