windows - 如何让用户的Windows版本低于Windows 8时程序退出?

标签 windows batch-file version

我已经到处寻找,但没有发现任何可以帮助我的东西。

我当前的代码是

    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

关于windows - 如何让用户的Windows版本低于Windows 8时程序退出?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71418385/

相关文章:

windows - TPageControl 获取索引

windows - 如何将具有不同扩展名的文件作为 BAT 文件运行

C# 版本兼容性

open-source - 如何自动化发布开源软件的任务?

django - 在 Windows 上为 django 构建 docker 镜像时出现 gcc 错误

c++ - 我的小型转储变得太大而无法被 Visual Studio 加载,我该如何解决这个问题?

c# - 使用 Metro 风格应用程序启动桌面应用程序

windows - 批量重新打开文件

batch-file - 使用批处理文件复制目录路径中带有通配符的文件?

java - org.apache.commons.mail.MultiPartEmail 发送带有空正文的电子邮件