Details
-
Improvement
-
Status: Closed
-
Normal
-
Resolution: Fixed
-
FACT 2.4.6
-
None
-
2
-
Windows 2016-06-29
Description
Currently there are 2 WMI queries used to retrieve the operating system release version for Windows:
- SELECT version, producttype FROM Win32_OperatingSystem at
https://github.com/puppetlabs/facter/blob/2.x/lib/facter/operatingsystem/windows.rb#L9 - SELECT version FROM Win32_OperatingSystem at https://github.com/puppetlabs/facter/blob/2.x/lib/facter/kernelrelease.rb#L44
To enable broader OS support, we can simply use the GetVersionEx API call, as long as we use the OSVERSIONINFOEX structure to retrieve wProductType
Note that as of Windows 8.1, there are some interesting notes about how that API has changed that are worth validating -
Applications not manifested for Windows 8.1 or Windows 10 will return the Windows 8 OS version value (6.2). Once an application is manifested for a given operating system version, GetVersionEx will always return the version that the application is manifested for in future releases. To manifest your applications for Windows 8.1 or Windows 10, refer to Targeting your application for Windows.
|
Alternatively, we can use GetProductInfo, which requires a minimum of Windows 2008 and will return Major / Minor versions, but not the equivalent of wProductType, which is used for some older 2003 / XP detection (that could probably be rewritten).
There are also some Version Helper APIs, but it's unclear which OS version they support.