Home > Blockchain >  Detect Windows version and run command according to version
Detect Windows version and run command according to version

Time:10-28

I've found a way to make it work with this script

FOR /F "SKIP=1 TOKENS=1-2 DELIMS=." %%A IN ('WMIC OS GET VERSION'
) DO FOR %%C IN (%%A%%B) DO IF %%C EQU 62 GOTO :windows8

but this only works for a single version, and i would like to be able to add conditions to other versions

i've tried adding ELSE IF %%C EQU 100 GOTO :windows10 but it doesn't work

can someone help me?

CodePudding user response:

You can try like this in order to check Windows version :


@echo off
Title Check Windows Version
for /f "tokens=4-7 delims=[.] " %%i in ('ver') do (if %%i==Version (set v=%%j.%%k) else (set v=%%i.%%j))
if "%v%" == "10.0" set "myOS=Windows 10"
if "%v%" == "6.3" set "myOS=Windows 8.1"
if "%v%" == "6.2" set "myOS=Windows 8"
if "%v%" == "6.1" set "myOS=Windows 7"
if "%v%" == "6.0" set "myOS=Windows Vista"
if "%v%" == "5.2" set "myOS=Windows XP" & REM WinXP 64Bit Edition
if "%v%" == "5.1" set "myOS=Windows XP"
if "%v%" == "5.0" set "myOS=Windows 2000"
cls
echo Current OS version: %myOS%
pause >NUL
@exit /B
  • Related