Find 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.

Find windows version from command line

Searches for a string of text in a file or files, and displays lines of text that contain the specified string.

Syntax

Parameters

Parameter Description
/v Displays all lines that don’t contain the specified .
/c Counts the lines that contain the specified and displays the total.
/n Precedes each line with the file’s line number.
/i Specifies that the search is not case-sensitive.
[/off[line]] Doesn’t skip files that have the offline attribute set.
Required. Specifies the group of characters (enclosed in quotation marks) that you want to search for.
[ :][

] Specifies the location and name of the file in which to search for the specified string. /? Displays help at the command prompt.

Remarks

If you don’t use /i, this command searches for exactly what you specify for string. For example, this command treats the characters a and A differently. If you use /i, however, the search becomes non-case-sensitive, and it treats a and A as the same character.

If the string you want to search for contains quotation marks, you must use double quotation marks for each quotation mark contained within the string (for example, «»This string contains quotation marks»»).

If you omit a file name, this command acts as a filter, taking input from the standard input source (usually the keyboard, a pipe (|), or a redirected file) and then displays any lines that contain string.

You can type parameters and command-line options for the find command in any order.

You can’t use wildcards (* and ?) in file names or extensions that you specify while using this command. To search for a string in a set of files that you specify with wildcards, you can use this command within a for command.

If you use /c and /v in the same command line, this command displays a count of the lines that don’t contain the specified string. If you specify /c and /n in the same command line, find ignores /n.

This command doesn’t recognize carriage returns. When you use this command to search for text in a file that includes carriage returns, you must limit the search string to text that can be found between carriage returns (that is, a string that is not likely to be interrupted by a carriage return). For example, this command doesn’t report a match for the string tax file if a carriage return occurs between the words tax and file.

Examples

To display all lines from pencil.ad that contain the string pencil sharpener, type:

To find the text, «The scientists labeled their paper for discussion only. It is not a final report.» in the report.doc file, type:

To search for a set of files, you can use the find command within the for command. To search the current directory for files that have the extension .bat and that contain the string PROMPT, type:

To search your hard disk to find and display the file names on drive C that contain the string CPU, use the pipe (|) to direct the output of the dir command to the find command as follows:

Because find searches are case-sensitive and dir produces uppercase output, you must either type the string CPU in uppercase letters or use the /i command-line option with find.

How to get Windows version from command prompt or from PowerShell

But is there a way to get the exact version string using command line output similar to the one mentioned in the image?

The attached is the output of «winver» command from run. PS: I am looking for a batch or PowerShell command.

There are some alternates available to get the Windows version like this PowerShell command:

6 Answers 6

The following commands are is going to help you with that. If you need more information, just type in systeminfo:

The ver command shows something like this:

But in PowerShell (or Git Bash) you have to call it through the cmd command:

I found it somewhere, PowerShell:

To add to @Bonifacio ‘s answer:

Would be even better, because it returns only the ReleaseId value, which you could then pipe to a file. Especially useful if you have several hosts to deal with.

With system information you can only get the build with that value and go to Google to get the respective version.

However, one simple way is by searching the registry on the command line:

The reg query way suggested all output a little garbage.

Using a for loop with tokens will output clean information.

The tokens=3 refers to the third word from the original output.

You will need to double the % if running inside a bat file.

You can set the output as a variable by replacing echo %i with set build=%i

Also remember to escape ^ any special characters.

Lastly look at HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion for the string that has the required value. You may need to adjust the token count.

How to do a simple file search in cmd

I want to quickly search for a file given its name or part of its name, from the windows command line (not power shell). This is similar to opening explorer and using the search box at the top.

Note: dir can search based on a string template but it will not search in the subdirectories.

Note2: findstr can be used to search for a token inside files and has a recursivity flag; it’s funny that a more complex find can be easily discovered .

5 Answers 5

dir /s *foo* searches in current folder and sub folders.

It finds directories as well as files.

/s Lists every occurrence of the specified file name within the specified directory and all subdirectories.

searches for all txt file in the directory tree. Before using it just change the directory to root using

you can also export the list to a text file using

and search within using

EDIT 1: Although this dir command works since the old dos days but Win7 added something new called Where

will search for exe & dll in the drive c:\Windows as suggested by @SPottuit you can also copy the output to the clipboard with

just wait for the prompt to return and don’t copy anything until then.

EDIT 2: If you are searching recursively and the output is big you can always use more to enable paging, it will show — More — at the bottom and will scroll to the next page once you press SPACE or moves line by line on pressing ENTER

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.

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.

Читайте также:  Антивирус dr web для windows 32 bit
Оцените статью