@@ -74,20 +74,19 @@ static string GetWindowsVersion()
7474 if ( key == null )
7575 return $ "Windows { Environment . OSVersion . Version } ";
7676
77- var productName = key . GetValue ( "ProductName" ) ? . ToString ( ) ?? "Unknown Windows" ;
77+ var productName = key . GetValue ( "ProductName" ) ? . ToString ( ) ?? "Windows" ;
7878 var currentBuild = key . GetValue ( "CurrentBuild" ) ? . ToString ( ) ?? "Unknown Version" ;
79-
79+ var displayVersion = key . GetValue ( "DisplayVersion" ) ? . ToString ( ) ;
8080 if ( Helpers . IsWindows11OrGreater ( ) )
8181 productName = productName . Replace ( "10" , "11" ) ;
82- if ( BuildToFriendlyName . TryGetValue ( currentBuild , out string friendlyName ) )
83- {
84- return $ "{ productName } { friendlyName } ";
85- }
8682
87- if ( int . TryParse ( currentBuild , out int currentBuildNumber ) )
83+ if ( int . TryParse ( currentBuild , out var currentBuildNumber ) && displayVersion is null )
8884 {
85+ if ( BuildToFriendlyName . TryGetValue ( currentBuild , out var friendlyName ) )
86+ {
87+ return $ "{ productName } { friendlyName } ";
88+ }
8989 var closestMatch = BuildToFriendlyName
90- . Where ( kvp => int . TryParse ( kvp . Key , out int buildNumber ) )
9190 . Select ( kvp => new { BuildNumber = int . Parse ( kvp . Key ) , FriendlyName = kvp . Value } )
9291 . OrderBy ( match => Math . Abs ( currentBuildNumber - match . BuildNumber ) )
9392 . FirstOrDefault ( ) ;
@@ -98,7 +97,7 @@ static string GetWindowsVersion()
9897 }
9998 }
10099
101- return $ "{ productName } { currentBuild } ";
100+ return displayVersion is not null ? $ " { productName } { displayVersion } " : $ "{ productName } { currentBuild } ";
102101 }
103102 catch ( Exception ex )
104103 {
0 commit comments