如果用户的 Windows 版本低于 Windows 8,我该如何使程序退出?

How do I make it so that the program will exit if the user's Windows version is lower than Windows 8?

我到处找,但没有找到任何可以帮助我的东西。

我目前的密码是

    if "%version%" == "6.0" echo Windows Vista is not supported by this program, as the commands this program uses are not in Windows Vista.
pause
exit

if "%version%" == "6.1" echo Windows 7 is not supported by this program, as the commands this program uses are not in Windows 7. 
pause
exit

if "%version%" == "6.2" echo Windows 8 support with this program has not been tested, this program may not work if some commands that are used in this program are not in Windows 8, If you would like to continue, please press "1", press "0" if you would like to exit.
choice /c ecsf /m "Choose your option."
if %ERRORLEVEL% EQU 1 goto MENU
if %ERRORLEVEL% EQU 0 exit

if "%version%" == "6.3" echo Windows 8.1 support with this program has not been tested, this program may not work if some commands that are used in this program are not in Windows 8, If you would like to continue, please press "1", press "0" if you would like to exit.
choice /c ecsf /m "Choose your option."
if %ERRORLEVEL% EQU 1 goto MENU
if %ERRORLEVEL% EQU 0 exit

Windows 8 发布 version is 6.2.* 不考虑补丁。 所以你需要对没有补丁的版本和大于 61 的版本进行整数比较。您可以使用:

@echo off

for /f "tokens=2 delims=[" %%# in ('ver') do (
    for /f "tokens=2,3 delims=. " %%a in ("%%#") do set r_vers=%%a%%b
)

echo %r_vers%

if %r_vers% LSS 62 (
  echo you need at least Windows 8
  pause
  exit /b 1
)

echo continue with the script
pause