Find windows OS version from command line
SATURDAY, AUGUST 29, 2009LEAVE A COMMENT
Windows has command line utilities that show us the version of the Windows OS we are using including the
service pack number.
If you just want to find the OS name from command line you can use ver command. Just 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:\>
As you can see above, ver command just tells you the OS name but not the service pack number you are
using. We can find service pack number as well as the OS name using Systeminfo command. But Systeminfo
command dumps lot of other information also. So we need to use findstr command to filter out unwanted
information.
systeminfo | findstr /B /C:"OS Name" /C:"OS Version"
Example:
C:\>systeminfo | findstr /B /C:"OS Name" /C:"OS Version"
OS Name: Microsoft Windows XP Professional
OS Version: 5.1.2600 Service Pack 2 Build 2600
Thanks to Monk for providing this tip in the comments.
This command works on XP, Vista and Windows 7 and on Server editions also. Find below example for Win7.
C:\>systeminfo | findstr /B /C:"OS Name" /C:"OS Version"
OS Name: Microsoft Windows 7 Ultimate
OS Version: 6.1.7600 N/A Build 7600
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:
The below wmi command gives the OS and the service pack version.
wmic os get Caption,CSDVersion /value