Determining the version of Microsoft Windows from the command line

Learning that lasts. Online courses from $14.99
You can determine the version of Microsoft Windows on a system from a command line interface (CLI), e.g. by opening a command prompt window, using the systeminfo command. Since that command will provide a lot of other information on the system, you can filter the output to see only the operating system (OS) version by piping its output into the findstr command using the "|" pipe character. The command below will show only the operating system version:
C:\>systeminfo | findstr /R "^OS.Version"
OS Version:                10.0.10586 N/A Build 10586

C:\>

The /R option indicates that the findstr command should perform its search based on a regular expression. The "^" character is a character that when included in a regular expression means that what follows should be at the beginning of the line. Without it, you could see something like the following, instead, since "BIOS Version also matches:

C:\>systeminfo | findstr /R "OS.Version"
systeminfo | findstr /R "OS.Version"
OS Version:                10.0.10586 N/A Build 10586
BIOS Version:              Dell Inc. A04, 11/21/2011

C:\>

The period between "OS" and "Version" indicates in a regular expression that any one character in that space will match; in this case there is a space character between the two words, which will match the period in a regular expression. If you want to have a period treated as a period rather than serving its function as a regular expression character, you can "escape" its meaning by using the backslash, i.e. "\", escape character.

If you wished to see other information about the OS, you could pipe the output to the find command and search on "OS " as shown below:

C:\>systeminfo | find "OS "
systeminfo | find "OS "
OS Name:                   Microsoft Windows 10 Pro
OS Version:                10.0.10586 N/A Build 10586
OS Manufacturer:           Microsoft Corporation
OS Configuration:          Member Workstation
OS Build Type:             Multiprocessor Free
BIOS Version:              Dell Inc. A04, 11/21/2011

C:\>

You can determine if it is a 32-bit or 64-bit version of Microsoft Windows using the commands below:

C:\>systeminfo | findstr /C:"System Type"
System Type:               x64-based PC

C:\>

If you wish to get both pieces of information at once, you can use the commands below:

C:\>systeminfo | findstr /R "^OS.Version System.Type"
OS Version:                10.0.10586 N/A Build 10586
System Type:               x64-based PC

C:\>

When you separate strings by a space, the findstr command interprets that to mean you want to find all lines that match any of the strings. So, for the example above, it will display any lines where it finds a match for either "OS Version" or "System Type".

If you also wish to know the date and time the version of the operating system now on the system was installed, you could use the commands below, since the installation date appears in a line that begins with "Original Install Date:".

C:\>systeminfo | findstr /R "^OS.Version System.Type Original.Install.Date"
OS Version:                10.0.10586 N/A Build 10586
Original Install Date:     7/30/2016, 2:43:26 AM
System Type:               x64-based PC

C:\>

Note: the date and time reflect the installation of the version of Microsoft Windows currently on the system. E.g., if the system was running version 7, but was upgraded to Windows 10, the date and time would reflect the date and time Windows 10 was installed, not the date and time Windows 7 was installed.

You can include the name of the operating system, e.g., "Microsoft Windows 10 Professional" as well using the command below:

C:\>systeminfo | findstr /R "^OS.[NV] System.Type Original.Install.Date"
OS Name:                   Microsoft Windows 10 Pro
OS Version:                10.0.10586 N/A Build 10586
Original Install Date:     7/30/2016, 2:43:26 AM
System Type:               x64-based PC

C:\>

By putting "NV" in brackets, findstr will look for any lines that begin with "OS" followed by any character and then the character "N" or "V". Including characters between brackets in a regular expression means that any character within the brackets will match. In this case that means "OS Version" and "OS Name" both match the regular expression, since the regular expression specifies that a line can begin with "OS" followed by any character and then either "N" or "V".

Another method that you can use to determine the operating system version from a command prompt is by using a WMIC command as shown below:

C:\>wmic os get version
wmic os get version
Version
10.0.10586


C:\>

You can use another WMIC command to determine if it is a 32-bit or 64-bit version of Windows:

C:\>wmic os get OSArchitecture
wmic os get OSArchitecture
OSArchitecture
64-bit


C:\>

You can get the version number and the 32 versus 64-bit information by including both parameters on the command line as shown below:

C:\>wmic os get Version, OSArchitecture
wmic os get Version, OSArchitecture
OSArchitecture  Version
64-bit          10.0.10586


C:\>

To include the date the version of the operating system currently on the system was installed, as well, you can use the command below:

C:\>wmic os get Version, OSArchitecture, InstallDate
wmic os get Version, OSArchitecture, InstallDate
InstallDate                OSArchitecture  Version
20160730024326.000000-240  64-bit          10.0.10586


C:\>

You will note that the date and time are displayed in a different format than in the output from the systeminfo command. In the example above, which was run on the same system as the systeminfo command, the installation date format is YYYYMMddhhmm followed by a period and then fractions of a second where YYYY represents the 4-digit year, MM the two-digit month, dd the day, hh the hour in 24-hour clock format, mm the minutes.

To include the descriptive name for the OS as well, you can use the command below:

C:\>wmic os get Version, OSArchitecture, InstallDate, Name
InstallDate                Name                                                              OSArchitecture  Version
20160730024326.000000-240  Microsoft Windows 10 Pro|C:\WINDOWS|\Device\Harddisk0\Partition3  64-bit          10.0.10586


C:\>

The output is somewhat difficult to read; you can change the format to display the output in list format by appending "/format:list" to the command.

C:\>wmic os get Version, OSArchitecture, InstallDate, Name /format:list
InstallDate=20160730024326.000000-240
Name=Microsoft Windows 10 Pro|C:\WINDOWS|\Device\Harddisk0\Partition3
OSArchitecture=64-bit
Version=10.0.10586;

Related articles:

  1. Obtaining a Command Prompt on a Windows 8 System
    Date: February 20, 2017
  2. Obtaining a command prompt in Windows 10
    Date: February 18, 2017
  3. Obtaining a command prompt in Windows 11
    Date: August 14, 2023