Search code examples
batch-filegoto

Batch exclude windows, with ver command


I want a code who jump to :jumpto if the windows is older than windows 8 (win 7 and older)

IF "windows is older than Windows 8" 6.2.9200.16384 goto jumpto'

I cannot formulate the correct code. Anyone who can help me out please?

I guess if i can use ver and calculate if numbers are lower than 6.2?


Solution

  • This should work:

    @ECHO OFF
    FOR /F "tokens=*" %%a IN ('ver') DO (
        SET ver=%%a
    )
    SET v1=%ver:~27,1%
    SET v2=%ver:~29,1%
    IF %v1% LSS 6 GOTO JUMPTO
    IF %v2% LSS 2 GOTO JUMPTO
    ECHO doing something
    PAUSE
    GOTO:EOF
    :JUMPTO
    ECHO Windows version too old!
    PAUSE