Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reliable way to get Windows Version from registry

I'm checking the windows version in an installer (made with NSIS) by checking the following registry key:

HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" "CurrentVersion"

According to this post and this page from MSDN, the currentVersion number for Windows 10 should be 10.0.

I just installed the Windows 10 Pro Insider Preview and the version number given in the registry is still 6.3, instead of 10.10 as it should.

Is there another reliable way in registry to detect Windows 10?

like image 804
skuallpa Avatar asked Jun 26 '15 11:06

skuallpa


People also ask

How check OS build in registry?

1 – Press and hold windows logo key and press R on your keyboard to open run. 2 – Now, type regedit in it. 3 – Now, in the registry editor go to the following location from the left side menu. 4 – In the right side all the build number, version number are written.

What version of Windows 10 do I have registry?

Open Settings and go to System - About. On the right, look for the Edition line. You can find your Windows 10 edition in the command prompt. You can find your Windows 10 edition in Registry.

How do I know if Windows 11 is in the registry?

Find Windows 11 Version Number in Registry Editor 1 Open Registry Editor (regedit.exe). 3 In the right pane of the CurrentVersion key, look to see what the data (ex: "21H2") shows for the DisplayVersion string value. This will be the version number.


4 Answers

Instead of reading the value CurrentVersion, read the new values CurrentMajorVersionNumber (which is 10) and CurrentMinorVersionNumber (which is 0) under Windows 10. Those 2 keys are new in Windows 10 to detect Windows Version from Registry.

like image 57
magicandre1981 Avatar answered Oct 04 '22 20:10

magicandre1981


There's also a human-readable string in the registry called "ProductName"

using Microsoft.Win32;
private string getOSInfo()
{
   string registry_key = @"SOFTWARE\Microsoft\Windows NT\CurrentVersion";
   var key = Registry.LocalMachine.OpenSubKey(registry_key);
   var value = key.GetValue("ProductName");
   return value.ToString();
}
like image 43
pav Avatar answered Oct 04 '22 21:10

pav


Try

HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProductName
HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ReleaseId

Which gives me 10 and 1709.

like image 40
Temujin Avatar answered Oct 04 '22 22:10

Temujin


See Peter Bright's article at https://arstechnica.com/information-technology/2014/11/why-windows-10-isnt-version-6-any-more-and-why-it-will-probably-work/ for more insight on why you see the answers you do. As you already saw from @magicandre1981, the CurrentMajorVersionNumber key will give you the "10" you want. You can get 10.0 from System.Environment.OSVersion if the application manifest explicitly designates your app for Windows 10, as stated in the referenced article. Without it, Environment.OSVersion will give you 6.2.9200, which is the same as Windows 8. So, your Windows 10 version is 10.0, 6.3, or 6.2, depending on how you ask the question.

like image 26
John Whitmire Avatar answered Oct 04 '22 20:10

John Whitmire