3

In the past i was using the major/minor number received from the ver tool in case i need to execute OS specific commands. With the release of Windows 11 it looks like this wouldn't work anymore (at least for now).

At the moment i don't check for the micro number so the script will handle windows 11 as windows 10 but i assume it could cause problems in future.

Here is a table that shows some versions

<Here should be an preview Image that shows the version of Win10 21H1 and Win 11 21H2 but im not allowed to embed it>

Can somebody explain how the versioning related to Windows 10 and Windows 11 will continue? (will Windows 10 stay in the range between 19043 and 22000 ?)

Io-oI
  • 9,237
Regda
  • 33

2 Answers2

0

The windows 10 builds all have 19 or less in the third number: ex. 10.X.19XXX.

The Windows 11 builds will all have 22 or higher: ex 10.X.22XXX.

You can think of windows 11 as windows 10 with a higher feature set, similar to how windows 10 v1809 is a downgrade feature set from w10v1909

David Shader
  • 301
  • 2
  • 11
0

Why this is the best answer ?

Because it lets you:

  1. Use arithmetic operators for comparison (EQU, NEQ, GTR, LSS, LEQ, GEQ), for a range of OSes, or if you want one not above and not under a certain OS (like any OS between 7:10), thanks to the leading 0.
  2. Easily distinguish between versions of Windows 10, 11, 12 and vNext (until Windows 40 where the script collapses).
  3. It works even in non-English Windows' where Version can be Versione or something else.
  4. You can quickly/easily test the script against various cases by replacing ('ver') with (%TESTstring%) without having to go to a real/virtual OS to test.

Explanation

  • We start parsing from token #3 which can be XP, Version, Versione, etc.., if its XP, we jump 2 steps ahead, so instead of starting with %%j we use %%k.%%l. If its not XP we just use %%j.%%k, unless its Win 10 or above, then we use %%j.%%k.%%l to easily grasp major.minor.build parts.
  • The arithmetic operators for comparison: EQU, NEQ, GTR, etc.. is done char by char like normal string sorting, so 10.0 is less than 6.3, because 6 is greater than 1, so we've to add a leading 0 if Windows is less than 10 for the comparison to work correctly. Remember to use the leading 0 for any comparison.
  • gtr 3 determines when we should put a leading 0, because we don't want a 2 digits version to be: 010.0.22000, also making it gtr 3 here will fail with very old OSes like Win 3.1, if you want to make the script aware of that too then maybe make it 'gtr 2', but this will make the last supported version it can detect is not v39 but Windows v29.

Batch

@echo off
set TESTstring="Microsoft Windows [Version 39.0.99999]"
REM set TESTstring="Microsoft Windows [Version 10.0.22621]"
REM set TESTstring="Microsoft Windows [Version 10.0.22000]"
REM set TESTstring="Microsoft Windows [Version 10.0.10240]"
REM set TESTstring="Microsoft Windows [Version 6.3.9600]"
REM set TESTstring="Microsoft Windows [Version 6.1.7601]"
REM set TESTstring="Microsoft Windows XP [Version 5.1.2600]"
REM set TESTstring="Microsoft Windows [Version 4.10]"

Set osName=Unknown Windows for /f "tokens=3-7 delims=[.] " %%i in ('ver') do @(if %%i==XP (set os_ver_org=%%k.%%l) else (if %%j geq 10 (set os_ver_org=%%j.%%k.%%l) else (set os_ver_org=%%j.%%k))) set os_ver=%os_ver_org% if %os_ver_org:~0,1% gtr 3 set os_ver=0%os_ver_org%

REM If we live to see W12, replace 10.0.44000 below with the correct build and modify W11 line to add "lss 10.0.44000" REM if %os_ver% GEQ 10.0.44000 set osName=Windows 12

if %os_ver% GEQ 10.0.22000 set osName=Windows 11 if %os_ver% GEQ 10.0.10240 if %os_ver% lss 10.0.22000 set osName=Windows 10 if %os_ver% equ 06.3 set osName=Windows 8.1 if %os_ver% equ 06.2 set osName=Windows 8 if %os_ver% equ 06.1 set osName=Windows 7 if %os_ver% equ 06.0 set osName=Windows Vista if %os_ver% equ 05.2 set osName=Windows XP x64 or Server 2003 if %os_ver% equ 05.1 set osName=Windows XP if %os_ver% equ 05.0 set osName=Windows 2000 if %os_ver% lss 05.0 set osName=Windows ME or 98 or less

echo Detected %osName% x%PROCESSOR_ARCHITECTURE:~-2% (%os_ver_org%) if %os_ver% lss 06.3 echo Only Windows 8.1 or above are supported !