Determine Windows Version
Who would have thought a simple question like "what version of windows am I running under?" would be so complicated?
This stub retrieves the number as a string. A complete working script which parses ver and responds accordingly is attached as winver2.cmd. For practical purposes you might be better off with Simon Sheppard's approach.
~~~~ {.prettyprint} @echo off for /f "tokens=2 delims=[]" %%x in ('ver') do set WINVER=%%x set WINVER=%WINVER:Version =% echo CMD version is %winver% ~~~~
A one liner for the major number (reg.exe not always available, XP and newer I think):
reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v CurrentVersion
References
- http://ss64.com/nt/ver.html
- http://en.wikipedia.org/wiki/Microso...ne_of_releases
- http://ss64.org/viewtopic.php?id=879
- http://stackoverflow.com/questions/1...-is-running-on
Windows Version Table
Scraped from http://en.wikipedia.org/wiki/Microso...ne_of_releases
Product name
Current Version / Build
1.01
2.03
2.10
2.11
3.0
3.1
3.1
NT 3.1
3.11
Windows 3.2 (released in Simplified Chinese only)
3.2
NT 3.5
NT 3.51
4.0.950
NT 4.0.1381
4.10.1998
4.10.2222
NT 5.0.2195
4.90.3000
NT 5.1.2600
Windows XP 64-bit Edition (IA-64)
NT 5.2.3790
NT 5.2.3790
Windows XP Professional x64 Edition
NT 5.2.3790
Windows Fundamentals for Legacy PCs
NT 5.1.2600
NT 6.0.6002
NT 5.2.4500
NT 6.0.6002
Windows 7 and Windows Server 2008 R2
NT 6.1.7600
Unknown