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
if exist %SystemRoot%\system32\systeminfo.exe (
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
From serverfault
WileCau
-
Check this thread: http://stackoverflow.com/questions/1792740/how-to-tell-what-version-of-windows-and-or-cmd-exe-a-batch-file-is-running-on
WileCau : @Sergey, thanks for the link. Using ver was my first thought but it isn't definitive or consistent enough, e.g. NT returns "Windows NT Version 4.0", XP returns "Microsoft Windows XP [Version 5.1.2600]", Server 2008 returns "Microsoft Windows [Version 6.1.7600]". Using the version number to infer the OS Name can result in ambiguity, e.g. the other thread has results like "Windows Vista or Windows Server 2008". The OS Name from systeminfo tells you exactly which one it is, without the need for interpretation. The link told me about %PROCESSOR_ARCHITECTURE% though, which I also need :) ThanksFrom Sergey
0 comments:
Post a Comment