Skip to content

Commit 3fce07d

Browse files
committed
Correctly reporting Windows 11 version
1 parent 31ecb59 commit 3fce07d

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

src/SDK/NET/Utils/SystemInfo.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,7 @@ public static string OperatingSystemDescription
697697
description = $"{OperatingSystem} ({OperatingSystemName} {OperatingSystemVersion}";
698698

699699
if (!OperatingSystemCodeName.StartsWith(OperatingSystem))
700-
description += $" \"{OperatingSystemCodeName}\"";
700+
description += $" {OperatingSystemCodeName}";
701701

702702
description += ")";
703703

@@ -1743,6 +1743,19 @@ private async static Task GetOsDetailsAsync()
17431743
{
17441744
_osVersion = "11";
17451745
_osCodeName = "Sun Valley";
1746+
1747+
string command = "reg";
1748+
string args = "query \"HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\" /v DisplayVersion";
1749+
string pattern = "DisplayVersion REG_SZ (?<version>[A-Z\\d]+)";
1750+
var options = RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture;
1751+
1752+
var results = await GetProcessInfoAsync(command, args, pattern, options).ConfigureAwait(false);
1753+
if (results is not null)
1754+
{
1755+
string? version = results["version"]?.Trim(); // eg. "23H2"
1756+
if (!string.IsNullOrWhiteSpace(version))
1757+
_osCodeName = version;
1758+
}
17461759
}
17471760
else
17481761
{

src/scripts/utils.bat

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2007,6 +2007,9 @@ REM Get Windows Version
20072007
if !ver_build! GEQ 22000 (
20082008
set "windows_version=Windows 11"
20092009
set "os_code_name=Sun Valley"
2010+
for /f "tokens=2,*" %%A in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v DisplayVersion 2^>nul ^| find "DisplayVersion"') do (
2011+
set os_code_name=%%B
2012+
)
20102013
) else (
20112014
set "windows_version=Windows 10"
20122015
set "os_code_name=Redstone"

src/setup.bat

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,7 @@ set freeSpaceBytes=!freeSpaceBytes:,=!
352352
set /a freeSpaceGb=!freeSpaceBytes:~0,-3! / 1048576
353353
set /a freeSpaceGbFraction=!freeSpaceBytes:~0,-3! %% 1048576 * 10 / 1048576
354354

355+
if "!volumeName!" == "no" set volumeName=(No label)
355356
if "!volumeName!" == "" set volumeName=(No label)
356357

357358

@@ -389,7 +390,7 @@ call "!utilsScript!" WriteLine ""
389390
:: Output settings
390391
if /i "%verbosity%" neq "quiet" (
391392
call "!utilsScript!" WriteLine
392-
call "!utilsScript!" WriteLine "os, name, arch = !os! !os_name! !architecture!" !color_mute!
393+
call "!utilsScript!" WriteLine "os, name, arch = !os! !os_name! (!os_code_name!) !architecture!" !color_mute!
393394
call "!utilsScript!" WriteLine "systemName, platform = !systemName!, !platform!" !color_mute!
394395
call "!utilsScript!" WriteLine "edgeDevice = !edgeDevice!" !color_mute!
395396
call "!utilsScript!" WriteLine "setupMode = !setupMode!" !color_mute!

0 commit comments

Comments
 (0)