Check windows version from command line

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.

Find OS Version and Service Pack number from CMD

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. Systeminfo dumps lot of other information too, which we can filter out using findstr command.

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

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

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

Check Windows version using WMIC command

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

Example on Windows 7:

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.

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

What version of Windows do I have?

As a Windows user, it’s important to know which operating system version you are using. You need this information when installing new programs and also for troubleshooting.

Microsoft provides details about the Windows version installed on your computer in several places in the operating system, e.g. in the Control Panel. There are three different ways of accessing the relevant system information. Let’s take a look at them now.

Checking your Windows version using a keyboard shortcut

The quickest way to find out your Windows version is using a keyboard shortcut. On newer systems, the steps are as follows:

  1. Simultaneously press the [Windows] key and the [Pause] key.
  2. A system information window will appear.

Under the heading “View basic information about your computer”, you will see the name of your operating system, e.g. Windows 10 Enterprise.

The window also contains an overview of the technical characteristics of your system, for example: processor architecture, installed memory (RAM) and system type (i.e. 32-bit or 64-bit). The next section shows the name of your computer and network domain settings. You can also see whether or not your Windows version is activated.

Читайте также:  Оформление windows иконки заставки курсоры

The system information window therefore contains all the information you need in order to install new programs.

However, it does not give you detailed information about your Windows version, such as the version number or the OS build number. You need this information if you want to check whether your operating system has all of the latest updates for example.

The [Windows] key + [Pause] key shortcut does not work on older Windows systems.

Windows: Command line to read version info of an executable file?

Does Windows have an executable that I can run in the command shell which returns the version number of an executable (.exe) file?

I see a lot of questions that show how to do it from different languages, and references to third party software to write it, but I can’t find a simple shell command to do it. Additional points if I don’t need to install anything.

It must be run as normal user. Not administrator.

7 Answers 7

You can use wmic to do it. And you can wrap it into a batch file

Save it as (example) getVersion.cmd and call as getVersion.cmd «c:\windows\system32\msiexec.exe»

edited to adapt to comments and not require administrator rights. In this case, an hybrid cmd/javascript file is used to query wmi. Same usage

If you are willing and able to use PowerShell, the following code will work. If you are on a supported Windows system, PowerShell will be available.

If you must run it in a cmd.exe shell, you could use:

This will give you only the file version:

and one way with makecab :

example output (it has a string version which is a small addition to wmic method 🙂 ):

also you can take a look at tooltipinfo.bat

filever c:\windows\system32\notepad.exe (the filever is preinstalled on every Windows OS).

filever.exe is in SUPPORT.CAB from the Windows 2003 Support tools, and maybe other places.

A method using VBScript and Scripting.FileSystemObject from a CMD script

A variant of the powershell method, if you are calling from a CMD script. Using FileVersionRaw instead of FileVersion, because FileVersion can have extra text decoration, but have to ToString() to get the expected format.

A Powershell from CMD method to compare versions, as that could be the reason for asking in the first place. Have to use %ErrorLevel%==x because ErrorLevel==x is actually greater or equal.

How to find the Windows version from the PowerShell command line

How do I find which Windows version I’m using?

I’m using PowerShell 2.0 and tried:

How do I do this?

25 Answers 25

Since you have access to the .NET library, you could access the OSVersion property of the System.Environment class to get this information. For the version number, there is the Version property.

Читайте также:  Что делать если эта копия windows не прошла проверку подлинности

Details of Windows versions can be found here.

To get the Windows version number, as Jeff notes in his answer, use:

It is worth noting that the result is of type [System.Version] , so it is possible to check for, say, Windows 7/Windows Server 2008 R2 and later with

However this will not tell you if it is client or server Windows, nor the name of the version.

Use WMI’s Win32_OperatingSystem class (always single instance), for example:

will return something like

Microsoft® Windows Server® 2008 Standard

Unfortunately most of the other answers do not provide information specific to Windows 10.

Windows 10 has versions of its own: 1507, 1511, 1607, 1703, etc. This is what winver shows.

As for other Windows versions use systeminfo . Powershell wrapper:

Windows 10 output for the same command:

This will give you the full version of Windows (including Revision/Build number) unlike all the solutions above:

Since PowerShell 5:

I think this command pretty much tries the 1001 different ways so far discovered to collect system information.

If you want to differentiate between Windows 8.1 (6.3.9600) and Windows 8 (6.2.9200) use

to get the proper version. [Environment]::OSVersion doesn’t work properly in Windows 8.1 (it returns a Windows 8 version).

I am refining one of the answers

I reached this question while trying to match the output from winver.exe:

Version 1607 (OS Build 14393.351)

I was able to extract the build string with:

Updated: Here is a slightly simplified script using regex

I took the scripts above and tweaked them a little to come up with this:

To get a result like this:

Microsoft Windows 10 Home 64-bit Version: 1709 Build: 16299.431 @

Hint: I’d appreciate a hand stripping the prefix text from the install date so I can replace it with a more readable header.

As MoonStom says, [Environment]::OSVersion doesn’t work properly on an upgraded Windows 8.1 (it returns a Windows 8 version): link.

If you want to differentiate between Windows 8.1 (6.3.9600) and Windows 8 (6.2.9200), you can use (Get-CimInstance Win32_OperatingSystem).Version to get the proper version. However this doesn’t work in PowerShell 2. So use this:

If you are trying to decipher info MS puts on their patching site such as https://technet.microsoft.com/en-us/library/security/ms17-010.aspx

you will need a combo such as:

$name=(Get-WmiObject Win32_OperatingSystem).caption $bit=(Get-WmiObject Win32_OperatingSystem).OSArchitecture $ver=(Get-ItemProperty «HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion»).ReleaseId Write-Host $name, $bit, $ver

Microsoft Windows 10 Home 64-bit 1703

To produce identical output to winver.exe in PowerShell v5 on Windows 10 1809:

Windows PowerShell 2.0:

Windows PowerShell 3.0:

For display (both versions):

This is really a long thread, and probably because the answers albeit correct are not resolving the fundamental question. I came across this site: Version & Build Numbers that provided a clear overview of what is what in the Microsoft Windows world.

Since my interest is to know which exact windows OS I am dealing with, I left aside the entire version rainbow and instead focused on the BuildNumber. The build number may be attained either by:

Читайте также:  Что такое missing operating system windows 10

the choice is yours which ever way you prefer it. So from there I could do something along the lines of:

Note: As you can see I used the above just for server systems, however it could easily be applied to workstations or even cleverly extended to support both. but I’ll leave that to you.

Windows commands

All supported versions of Windows (server and client) have a set of Win32 console commands built in.

This set of documentation describes the Windows Commands you can use to automate tasks by using scripts or scripting tools.

Prerequisites

The information that is contained in this topic applies to:

  • Windows Server 2019
  • Windows Server (Semi-Annual Channel)
  • Windows Server 2016
  • Windows Server 2012 R2
  • Windows Server 2012
  • Windows Server 2008 R2
  • Windows Server 2008
  • Windows 10
  • Windows 8.1

Command shell overview

The Command shell was the first shell built into Windows to automate routine tasks, like user account management or nightly backups, with batch (.bat) files. With Windows Script Host you could run more sophisticated scripts in the Command shell. For more information, see cscript or wscript. You can perform operations more efficiently by using scripts than you can by using the user interface. Scripts accept all Commands that are available at the command line.

Windows has two command shells: The Command shell and PowerShell. Each shell is a software program that provides direct communication between you and the operating system or application, providing an environment to automate IT operations.

PowerShell was designed to extend the capabilities of the Command shell to run PowerShell commands called cmdlets. Cmdlets are similar to Windows Commands but provide a more extensible scripting language. You can run Windows Commands and PowerShell cmdlets in Powershell, but the Command shell can only run Windows Commands and not PowerShell cmdlets.

For the most robust, up-to-date Windows automation, we recommend using PowerShell instead of Windows Commands or Windows Script Host for Windows automation.

You can also download and install PowerShell Core, the open source version of PowerShell.

Incorrectly editing the registry may severely damage your system. Before making the following changes to the registry, you should back up any valued data on the computer.

To enable or disable file and directory name completion in the Command shell on a computer or user logon session, run regedit.exe and set the following reg_DWOrd value:

To set the reg_DWOrd value, use the hexadecimal value of a control character for a particular function (for example, 0 9 is Tab and 0 08 is Backspace). User-specified settings take precedence over computer settings, and command-line options take precedence over registry settings.

Command-line reference A-Z

To find information about a specific command, in the following A-Z menu, click the letter that the command starts with, and then click the command name.

Оцените статью