Find windows OS version from command line

Windows has command line utilities that show us the version of the Windows OS running on the computer, including the service pack number. There are multiple CMD commands that help with finding this, you can pick the one that suits your need. Ver command can show you the OS version whereas Systeminfo command can additionally give you service pack, OS edition and build number etc.

If you want to find just the OS version, you can use ver command. Open command window and execute ver command. But note that this does not show service pack version.

C:\>ver
Microsoft Windows XP [Version 5.1.2600]
C:\>

This command does not show version on a Windows 7 system.

Finding version on Windows 7 system

Find OS Version and Service Pack number

As you can see above, ver command shows only OS version but not the service pack number. We can find service pack number as well with Systeminfo command. Systeminfodumps lot of other information too, which we can filter out using findstr command.

systeminfo | findstr /B /C:"OS Name" /C:"OS Version"

Examples:

C:\>systeminfo | findstr /B /C:"OS Name" /C:"OS Version"
Microsoft Windows XP Professional
OS Version:                5.1.2600 Service Pack 2 Build 2600

This command works on XP, Vista and Windows 7 and on Server editions also. Find below example for Win7.

systeminfo | findstr /B /C:"OS Name" /C:"OS Version"
OS Name:                   Microsoft Windows 7 Ultimate
OS Version:                6.1.7600 N/A Build 7600

In case of Windows 7 SP1, the output would be slightly different as below.

c:\>systeminfo | findstr /B /C:"OS Name" /C:"OS Version"
OS Name:                   Microsoft Windows 7 Enterprise
OS Version:                6.1.7601 Service Pack 1 Build 7601

If you want to print more details, then you can use just ‘OS’ in the findstr search pattern. See example below for Server 2008.

C:\>systeminfo | findstr /C:"OS"
OS Name:                   Microsoft Windows Server 2008 R2 Enterprise
OS Version:                6.1.7600 N/A Build 7600
OS Manufacturer:           Microsoft Corporation
OS Configuration:          Standalone Server
OS Build Type:             Multiprocessor Free
BIOS Version:              IBM -[BWE117AUS-1.05]-, 7/28/2005

Using WMI:

Run the below WMIC command to get OS version and the service pack number.

wmic os get Caption,CSDVersion /value

Example on Windows 7:

c:\>wmic os get Caption,CSDVersion /value
Caption=Microsoft Windows 7 Enterprise
CSDVersion=Service Pack 1