Display the current operating system version.


A very simple method of version checking is to pipe a version string into FIND, however there is a possibility that something which is a unique string today might match a minor version released in the future.

e.g. the following would also match "7.6.1"

ver | find "6.1" > nul
if %ERRORLEVEL% == 0 goto ver_2008R2

Batch file to find the current operating system version, for Vista and later:

@Echo off
For /f "tokens=4,5,6 delims=[]. " %%G in ('ver') Do (set _major=%%G& set _minor=%%H& set _build=%%I) 

Echo Major Version: [%_major%]
Echo Minor Version: [%_minor%]
Echo Build: [%_build%]

PowerShell to retrieve Version / Release ID

The VER command returns the Major/Minor / Build number, but does not include the Version/Release ID as displayed in Settings > About.

The Release ID is a 4 digit code - a 2 digit year plus 2 digit planned month of release. 1703,1809...
DisplayVersion is a 4 digit code - a 2 digit year plus H1 or H2.. for 1st, 2nd releases. 20H2, 21H1…

Mobile, Desktop and Server releases will have the same Version/Release ID but different build numbers.

For Windows 10 up to May 2020 / 2004, this can be retrieved from the registry via the ReleaseID:

$release = (Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion" -Name ReleaseId).ReleaseId

For all later versions, this can be retrieved from the registry via the DisplayVersion:

$ver = (Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion" -Name DisplayVersion).DisplayVersion

The ReleaseID is now deprecated and will return '2009' for 20H2 and all subsequent versions of Windows.

If ($release -lt '2009') {$release} Else {$ver}

List of Windows Version numbers

Windows Version Numbers
Product name Major version / build Release ID Version
Windows 95 4.0.950    
Windows XP 5.1.2600    
Windows Vista, Service Pack 2 6.0.6002    
Windows 7, RTM (Release to Manufacturing) 6.1.7600.16385    
Windows 8, RTM 6.2.9200.16384    
Windows 10 Gold 10.0.10240 1507  
Windows 10 November Update, 2015-11-03 10.0.10586 1511  
Windows 10 Aniversary Update 2016-08-02 10.0.14393.1794 1607  
Windows 10 Creators Update 2017-04-11 10.0.15063.674 1703  
Windows 10 Fall Creators Update 2017-10-17 10.0.16299.19 1709  
Windows 10 April 2018 Update 10.0.17134 1803  
Windows 10 October 2018 Update 10.0.17763.55 1809  
Windows 10 version 1903 (May 2019 Update) 10.0.18362.239 1903  
Windows 10 version 1909 (Nov 2019 Update) 10.0.18363 1909  
Windows 10 version 2004 (May 2020 Update) 10.0.19041 2004  
Windows 10 version 20H2 (October 2020 Update) 10.0.19042 2009 20H2
Windows 10 version 21H1 (May 2021 Update) 10.0.19043 2009 21H1
    2009 21H2

Server versions
Product name Major version / build Release ID Version
Windows Server 2003 5.2.3790    
Windows Server 2008 6.0.6001    
Windows Server 2008 R2, RTM 6.1.7600.16385    
Windows Server 2012 6.2.9200    
Windows Server 2012 R2 6.3.9600    
Windows Server 2016 RTM 2016-09-26 10.0.14393 1607  
Windows Server 2016 Aniversary Update 2017-03-22 10.0.14393.970 1703  
Windows Server 2016 Fall Creators Update 10.0.16299.15 1709  
Windows Server 2019 (Semi-Annual Channel) (Datacenter, Standard) 10.0.17134.1 1803  
Windows Server 2019 10.0.18342 1903  
Windows Server 2019 10.0.17763 1909  
Windows Server 2019 10.0.19041 2004  
Windows Server 2019 10.0.19042 2009 20H2
Windows Server 2022 (preview) 10.0.20285 2009  

See also Wikipedia list of Windows versions and Microsoft Windows 10 release history, support dates.

Finding the version remotely

PowerShell can be used to find the OS versions of multiple machines across a domain:

Get-ADComputer -Filter {OperatingSystem -like "Windows 10*"} -Property * | Format-Table Name,OperatingSystem,OperatingSystemVersion -Wrap –Auto

Service Pack Level

This batch script or this PowerShell script will return the Service Pack level.

32 bit or 64 bit process detection

The environment variable PROCESSOR_ARCHITECTURE holds the following possible values:

64-bit process: AMD64 or IA64
32-bit process or WOW64 (32bit Program on 64 bit OS): x86

If we are running WOW64 then PROCESSOR_ARCHITEW6432 =AMD64

  // OS is 32bit
  // OS is 64bit

via David Wang @MSFT


If the version was successfully displayed %ERRORLEVEL% = 0
If a bad parameter is given %ERRORLEVEL% = 1
VER /? will not reset the ERRORLEVEL, this is a bug.

VER is an internal command.

“Always be a first-rate version of yourself, instead of a second-rate version of somebody else” ~ Judy Garland

Related commands:

Win32_OperatingSystem OperatingSystemSKU - Retrieve the OS Type via WMI (sku=Stock Keeping Unit ).
Sigcheck - Check a file version, both OS files and others.
SystemInfo - Return OS, Service pack, BIOS, Memory etc.
WINVER.exe - In client OS's this will open the GUI Version dialogue box (Help, About)
Wikipedia - Timeline of Microsoft Windows - New features in each release.
PowerShell equivalent:
Get-ComputerInfo - Get system and OS properties.
OS Version - How to retrieve the OS version in PowerShell (several methods compared).
Equivalent bash command (Linux): uname -r - Print system information.

Copyright © 1999-2021
Some rights reserved