From ad4e68f2eff5828bae6541ba50c57a6a8a0793e4 Mon Sep 17 00:00:00 2001 From: TheCakeIsNaOH Date: Thu, 30 Jun 2022 16:24:17 -0500 Subject: [PATCH] (#2754) Add support for detecting newer Windows versions This allows Chocolatey CLI to detect Windows 11, Server 2019 and Server 2022. Which will allow the OS_NAME environment variable to be set correctly on those operating systems. --- src/chocolatey/infrastructure/platforms/Platform.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/chocolatey/infrastructure/platforms/Platform.cs b/src/chocolatey/infrastructure/platforms/Platform.cs index 5c9d003160..f7c45a5837 100644 --- a/src/chocolatey/infrastructure/platforms/Platform.cs +++ b/src/chocolatey/infrastructure/platforms/Platform.cs @@ -120,7 +120,15 @@ private static string get_windows_name(Version version) switch (majorMinor) { case "10.0": - name = isServer ? "Windows Server 2016" : "Windows 10"; + if (isServer) + { + name = (version.Build < 20348) ? (version.Build < 17763) ? + "Windows Server 2016" : "Windows Server 2019" : "Windows Server 2022"; + } + else + { + name = (version.Build < 22000) ? "Windows 10" : "Windows 11"; + } break; case "6.4": name = isServer ? "Windows Server 2016" : "Windows 10";