0

I want to programmatically find out what version of Windows a computer is running.

In the CMD shell one can type ver which for my computer returns:

Microsoft Windows [Version 6.2.9200]

But that can be the same on a server. Is there a command (maybe VBScript?) to find out the exact Windows version, such as Windows Server 2008?

7 Answers 7

4

An easy way in batch or Windows Commands.

You can use WMIC from the command line.

wmic os get caption

For my desktop it returns

Microsoft Windows 7 Professional

And on a server I have

Microsoft Windows Server 2012 Standard

Another option is to check server roles (To see if it actually is a server, or just running server OS)

0
0

Try:

wmic os get name

The result came out (for my system):

C:\Users\superuser>wmic os get name
Name
Microsoft Windows 8 Enterprise|C:\Windows|\Device\Harddisk2\Partition1
0

You could use the php_uname() function.

Example PHP script:

<?php
echo php_name();

Example output:

Windows NT #### 6.1 build 7601 (Windows 7 Ultimate Edition Service Pack 1) i586

I'm not immediately familiar of a VBScript implementation, sorry.

0

The WMI OperatingSystem class exposes the member 'OperatingSystemSKU' which should give you the answer you need, but it doesn't resolve for all os versions: http://msdn.microsoft.com/en-us/library/aa394239%28v=vs.85%29.aspx

On Error Resume Next 
' Connect to WMI and obtain instances of Win32_OperatingSystem
For Each objOS in GetObject( _
    "winmgmts:").InstancesOf ("Win32_OperatingSystem")

WScript.Echo "Name = " & objOS.Caption _
    & "Version = " & objOS.Version &VBCR _
    & "SKU = " & objOS.OperatingSystemSKU
Next

if Err <> 0 Then
    WScript.Echo Err.Description
    Err.Clear
End if
0

Yes

This works (and tested) on Windows Server 2008 and W7.

From the command prompt type

systeminfo | findstr /C:"OS"

And you'll get loads of information such as

enter image description here

Earlier versions of Windows may require

systeminfo | findstr /B /C:"OS Name" /C:"OS Version"
3
  • I learn something new.. never realized the "systeminfo" is available. Thanks Dave!
    – Darius
    Oct 9, 2013 at 12:00
  • Pleasure @darius.
    – Dave
    Oct 9, 2013 at 12:09
  • Two potential issues with this, Systeminfo is slow! And 2 the output looks like OS Name: Microsoft Windows 7 Enterprise Oct 10, 2013 at 14:59
0

The a quick way that you can go about finding the type of OS a Windows System is:

  1. Open Command Prompt
  2. systeminfo | findstr "OS Name"

Note: I'm adding in my answer, even though there are a few similar answers because I feel that the one that I posted is the most easily readable, making it easier to remember on the fly. Also it looks like it takes slightly less typing to boot.

Also, depending on the naming conventions that are being used for your network, you can also try entering hostname instead. For Example, the computers in my environment tend to be named "BLD##-SRV/WK-Sect##", making it fairly easy to figure out what a machine is and where it's located.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .