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, 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 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"
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
The below wmi command gives the OS and the service pack version.
wmic os get Caption,CSDVersion /value
Example on Win7:
c:\>wmic os get Caption,CSDVersion /value Caption=Microsoft Windows 7 Enterprise CSDVersion=Service Pack 1