views:

130

answers:

3

How can I check OS version in a batch file or through a vbs in an Windows 2k/2k3 environment ? You know ... Something like ... : "If winver Win2k then ... or if winver Win2k3 then ....

+2  A: 

Run the ver command and parse the string output that it gives you.

Russell Newquist
A: 

You should use ver and find.
Example:

ver | find "XP"
Soufiane Hassou
+3  A: 

you can use vbscript

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
 & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colOSes = objWMIService.ExecQuery("Select * from Win32_OperatingSystem")
For Each objOS in colOSes
  Wscript.Echo "Computer Name: " & objOS.CSName
  Wscript.Echo "Caption: " & objOS.Caption 'Name
  Wscript.Echo "Version: " & objOS.Version 'Version & build
Next

use the Caption to capture the string you want.

ghostdog74