Batch file to find and verify OS


By: Ortorea
December 8, 2011

I spent quite a while looking for a basic way to find the OS NAME of an Operating system without all the version numbers on the end so I can do a specific task based on the OS this is my result that I hope will help others writing batch files to do specific task based on result.

@echo off
setLocal EnableDelayedExpansion

for /f "tokens=1* delims=[" %%j in ('ver') do set myOS=%%j
echo ------------------------------------------------------------
echo This is the Version of MS Windows
echo which is Installed on this computer!
echo ++++++++++++++++++++
echo %myOS%
echo ++++++++++++++++++++
echo A text file containing this information
echo should now be on your desktop.
echo ------------------------------------------------------------
echo.
::
>> "C:\%HOMEPATH%\DESKTOP\My_Version.txt" echo %myOS%
if "%myOS%"=="Microsoft Windows XP " echo Verified: Microsoft Windows XP &&goto domything
goto done

:domything
echo your command here

:done
pause
:end
endlocal
exit

Michelle xxx


Need more help?
Describe your Problem
Example: Hard Drive Not Detected on My PC

Ask Question