Using systeminfo to get the OS Name

Posted by WileCau on Server Fault See other posts from Server Fault or by WileCau
Published on 2010-03-22T07:40:12Z Indexed on 2010/03/22 7:51 UTC
Read the original article Hit count: 201

Filed under:
|

I need to find the flavor of Windows that is running using a batch file that will run on anything from Windows NT to Windows 7. I'm using a method based on this page with some minor changes.

Systeminfo gives the flavor of Windows that is running. Is there any authoritative list of names that can be returned? If so where would I find the list?

My intention is to do something like:

 winVer=Unknown

 rem NT doesn't have systeminfo
 ver | find "Windows NT" > nul
 if %errorlevel%==0 set winVer=WinNT

 for /f "delims=: tokens=2" %%v in ('sysinfo ^| find "OS Name"') do (
  set verStr=%%v
 )
 echo %verStr% | find "Windows XP" > nul
 if %errorlevel%==0 set winVer=WinXP
 echo %verStr% | find "Windows Vista" > nul
 if %errorlevel%==0 set winVer=WinVista
 ... etc

Thanks

© Server Fault or respective owner

Related posts about Windows

Related posts about batch-file