The first line forces a WMI console installation if required on a new build. WMI always returns a consistent string of "Version=x.x.xxxx" so the token parsing is always the same for all Windows versions.
Parsing from the VER output has variable text preceding the version info, making token positions random. Delimiters are only the '=' and '.' characters.
The batch addition allows me to easily check versions as '510' (XP) up to '10000' for Win10. I don't use the Build value.
Setlocal EnableDelayedExpansion
wmic os get version /value 1>nul 2>nul
if %errorlevel% equ 0 (
for /F "tokens=2,3,4 delims==." %%A In ('wmic os get version /value') Do (
(Set /A "_MAJ=%%A")
(Set /A "_MIN=%%B")
(Set /A "_BLD=%%C")
)
(Set /A "_OSVERSION=!_MAJ!*100")
(Set /A "_OSVERSION+=!_MIN!*10")
)
endlocal