1

Windows' versioning structure has changed many times over the years. Over that time registry values have come and gone, and some still remain but contain old data. I would like a source that tells me how to build a detailed version string for each version of Windows.

I have found many non-offical sources but all of them are incomplete. I would like a source from Microsoft or a source approved by Microsoft.

https://ss64.com/nt/ver.html is the best I've found so far but it doesn't go into UBR or CSD

Kyle Berezin
  • 121
  • 6
  • What problem are you trying to sovle exactly by knowing which version of Windows is installed[?](https://superuser.com/questions/1519110/how-to-get-the-actual-version-number-for-windows-10-from-command-line-not-buil/1519122#1519122) – Ramhound Oct 06 '22 at 18:35
  • @Ramhound I am trying to add an exact version string to a log for debugging issues. The code runs on many different operating systems. – Kyle Berezin Oct 06 '22 at 18:41
  • A single registry key holds the information you are looking for, which you can use to record the information. I linked to information on approaches in my last comment. – Ramhound Oct 06 '22 at 18:45
  • What’s wrong with logging the output of `ver`? It uniquely identifies the Windows version, even if you may have to look at a table. // Not sure what you might be referring to by “UBR” or “CSD”. – Daniel B Oct 06 '22 at 18:50
  • @Ramhound ReleaseId is deprecated. – Kyle Berezin Oct 06 '22 at 18:52
  • @DanielB UBR is the "update build revision", it is just another versioning layer that Microsoft added. It was never documented to my knowledge but it is now part of the output of ver. CSD is like "service pack 2" and was removed for NT-10 (maybe?). I would prefer not to have to execute any commands through CMD. – Kyle Berezin Oct 06 '22 at 19:00
  • I'm also curious about this. `ver` is quite stellar, but a non -CLI technique would be more ideal (e.g. a win32 API, or a guideline for where the version information has shuffled to/from over the years).In my experience, ss64 is often THE authoritative location for these things, and for that reason, I donate to his charitable website annually to help keep it around. – tresf Oct 06 '22 at 19:24
  • Does `GetVersionEx` get you what you need (https://learn.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-getversionexw)? – heavyd Oct 06 '22 at 19:47
  • @heavyd Not quite. It really conforms to the Windows 95/XP version system. It is also deprecated. – Kyle Berezin Oct 06 '22 at 21:49
  • @KyleBerezin - Why do you say it’s depreciated? – Ramhound Oct 06 '22 at 22:35
  • @Ramhound "GetVersionEx may be altered or unavailable for releases after Windows 8.1" from that link. They suggest using version helper functions instead, which can narrow your version to greater than or less than one of 13 specific versions of Windows. The biggest problem with those though is they are not future-proof, any logic using it will break with the next version of windows. It is a pretty silly way to support version info in an api. – Kyle Berezin Oct 06 '22 at 23:16
  • @KyleBerezin - You pinged the wrong person, I never suggested GetVersionEx, I only suggested a registry key existed [here](https://superuser.com/questions/1519110/how-to-get-the-actual-version-number-for-windows-10-from-command-line-not-buil/1519122#1519122) that contained the information you wanted. – Ramhound Oct 06 '22 at 23:31
  • 1
    @Ramhound ReleaseID is 2009, and will be 2009 forever. I have found no authoritative source saying it is deprecated, but it no longer contains any useful info as of October 10 2020. That ss64 like I included talks a bit about it. – Kyle Berezin Oct 07 '22 at 03:49
  • Chiming in here... @Ramhound, the registry key is what I too use, but as Kyle mentions it seems to be trailing behind the likes of `ver`. – tresf Oct 07 '22 at 04:10
  • `any logic using it will break with the next version of windows` -- This is speculative. It may break. Note that Windows has deprecated many APIs over the years that still work decades later, such as [GDI](https://microsoft.fandom.com/wiki/Graphics_Device_Interface). – tresf Oct 07 '22 at 04:12
  • @tresf what I mean is, there is no function for detecting windows 12. This approach to detecting the version can never be futureproof. – Kyle Berezin Oct 07 '22 at 05:19
  • Gotcha. Well, in that case, fallback to the output of `ver`. It's the only thing you can blindly trust to work in the future, since the OS rather irrationally reports `10` as the major version for `Windows 11` and the minor versions for e.g. `Windows 12`, `Windows 13` haven't yet been published. Of course, this isn't to minimize the security risk of an OS blindly allowing an application to run console commands to begin with -- something sandboxed apps on certain platforms can't do -- but it's at least a detectable, known-working fallback that's most likely to keep working. – tresf Oct 07 '22 at 06:28
  • ... another rather crude approach is to blindly attempt to call `Windows11OrGreater` and increment... which despite being missing from [the official docs](https://learn.microsoft.com/en-us/windows/win32/sysinfo/getting-the-system-version) still manages [to be showing up](https://github.com/search?q=isWindows11OrGreater&type=code) in projects, some projects claiming it will [eventually be added](https://github.com/walbourn/walbourn.github.io/blob/3944cd6b583c5fc692060d7343a4540bd68dd543/_posts/2021-10-04-windows-sdk-for-windows-11.md). – tresf Oct 07 '22 at 06:39

0 Answers0