Find windows OS version from command line

by admin on January 29, 2009

How can one determine the operating system version from a Windows command prompt?

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"
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

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

Also Read:
Windows CMD commands reference

Find the version of the Windows running on your computer

{ 21 comments… read them below or add one }

Suchitra February 2, 2010 at 7:41 am

How to find windows edition ?

Reply

Techblogger February 12, 2010 at 5:45 pm

Execute 'Winver' from command prompt or from Run window. It will show you the windows version.

Reply

Monk April 17, 2010 at 11:31 pm

The "systeminfo" command gives the edition info under the headings "OS Name:" and "OS Version:" as well as a lot of other information all in the console. You can parse it with "findstr" if you need only the edition info:

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

Reply

Anonymous August 19, 2010 at 3:13 pm

I was looking for this…I had to write a script which runs on different windows editions and I need to capture the os name from command line..this post helped me..thank you..

Reply

Anonymous October 24, 2010 at 2:51 pm

Very helpful if I want to do a remote command without GUI. Thanks a ton!

Reply

Techblogger October 24, 2010 at 4:08 pm

Thanks for the comments. Glad that this post helped you..

Reply

Amit November 19, 2010 at 2:20 am

Thanks friend for the tip..I need to find os version from windows dos and this has helped me..

Reply

Anonymous November 23, 2010 at 6:58 pm

Thank you a lot!

I realy needed this tip.

Reply

Anonymous May 25, 2011 at 6:59 am

Thanks much! for sharing the info!

–Sannidhi–

Reply

Raj May 31, 2011 at 5:46 pm

How can I script this for multiple servers and save the output in csv format?

Reply

Techblogger June 1, 2011 at 7:25 am

Run the below command on each of the servers.

wmic os get buildnumber,caption,CSDVersion /format:csv

On my xp system it prints the following data.

Node,BuildNumber,Caption,CSDVersion
techblogger-pc,2600,Microsoft Windows XP Professional,Service Pack 2

You can use psexec.exe or rsh tool to run this command remotely on the servers.

Reply

Anonymous June 24, 2011 at 5:43 pm

How to find the bit size?

Reply

Techblogger June 26, 2011 at 1:16 pm

systeminfo | findstr /C:"System type" would give you the processor architecture. From this you can derive if it's 32 or 64 bit. You can also use wmic cpu command to get processor info.

Reply

Anonymous July 15, 2011 at 8:09 am

How to get the OS name and version for a list of servers ?

Reply

Techblogger July 15, 2011 at 8:16 am

Run the command mentioned in the post on each of the servers using psexec or rsh. I will soon add a post on psexec.

Reply

Anonymous August 12, 2011 at 7:49 am

WMIC /node:RemoteComputerName os get buildnumber,caption,CSDVersion /format:csv

can be used to retrieve information from a remote computer

Reply

Jackie October 26, 2011 at 8:07 am

Thank you for posting.

Reply

Lucas November 2, 2011 at 12:01 pm

I need to find the image version of a windows 7 installation. What command do I use to find out?

Reply

admin November 2, 2011 at 5:04 pm

If I have understood correctly, you have different images of Win7 and you want to find out which image you have installed on the computer? AFAIK, windows can’t do that.
I can think of a workaround for this. You can add custom reg key and set the image version number in that and then create the image. And on the installed computer, you can do reg query from command line.

Tim Kessler December 7, 2011 at 1:44 pm

The quotes are incorrect ASCII characters (MS Office quotes).

Use this version instead:

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

Reply

admin December 7, 2011 at 3:53 pm

I’ve fixed the issue in the post. Copy pasting the command would work fine now. Thank you for pointing that out.

Leave a Comment

Previous post:

Next post: