Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Determine OS

Status
Not open for further replies.

EBGreen

Programmer
Apr 1, 2004
2,867
US
Does anyone have a good way to determine the OS without using WMI?

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
You may simply grab the output of the VER command:
Dim oSh, oEx, OS
Set oSh=CreateObject("WScript.Shell")
Set oEx=oSh.Exec("%COMSPEC% /C ver")
Do While oEx.Status=0
WScript.Sleep 100
Loop
While Len(os)<1
os=Replace(oEx.StdOut.ReadLine,vbCrLf,"")
Wend
WScript.Echo "OS=" & os

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thank you very much...I knew there should be a simple answer. Just too frazzled to figure it out today.

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
With WMI.....
Code:
strComputer = "." 
Set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2") 
Set colItems = objWMI.ExecQuery("SELECT * FROM Win32_OperatingSystem",,48) 
For Each objItem in colItems 
    Wscript.Echo objItem.Caption
    Wscript.Echo objItem.Version
    Wscript.Echo "ServicePack " & objItem.ServicePackMajorVersion
Next
 
Well yeah, I knew the WMI way. I was explicitly looking for a non-WMI wya. Hence the "...without using WMI" part.

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
You mean like PHV posted?

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top