2

I have looked everywhere I could, and I found nothing that could help me.

The current code I have is

    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
ZacAttack
  • 23
  • 5
  • Please open a [command prompt](https://www.howtogeek.com/235101/), run `if /?` and read the output help. There is already described on first page the __IF__ condition syntax to use to evaluate the exit code of a command/program assigned to dynamic variable `ERRORLEVEL` which is `IF [NOT] ERRORLEVEL number command`. Next run `choice /?` and read again the output help. The exit code evaluation done by you is completely wrong. – Mofi Mar 10 '22 at 07:59
  • See also: [How to stop Windows command interpreter from quitting batch file execution on an incorrect user input?](https://stackoverflow.com/a/49834019/3074564) It explains in full details with examples how to handle the exit code of `%SystemRoot%\System32\choice.exe` correct and efficient if that executable is available at all which is by default not the case on Windows XP, just on Windows Server 2003 and newer server versions of Windows and Windows Vista and newer client versions of Windows. – Mofi Mar 10 '22 at 08:01

1 Answers1

3

Windows 8 release version is 6.2.* without taking into account the patches. So you need an integer comparison of the version without the patches and the version to be bigger than 61. You can use:

@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
npocmaka
  • 55,367
  • 18
  • 148
  • 187