windowsbatch-filecmdoperating-systemdetect

Batch file: Check if OS is Windows 10


I want to make a batch file which will do the following operation: checks if the running OS is windows. If it is than it should print Hello. Im win 10 else should print other message. How can i do this if condition?

Pseudocode:

if OS == Win10 then
   echo Hello im win 10
else
   echo I am another os

Solution

  • setlocal
    for /f "tokens=4-5 delims=. " %%i in ('ver') do set VERSION=%%i.%%j
    if "%version%" == "6.3" echo Windows 8.1
    if "%version%" == "6.2" echo Windows 8.
    if "%version%" == "6.1" echo Windows 7.
    if "%version%" == "6.0" echo Windows Vista.
    if "%version%" == "10.0" echo Windows 10.
    echo %version%
    rem etc etc
    endlocal