Login | |
|
 |
Short, Easy way to determine OS - 11/28/2005 8:00:24 AM
|
|
 |
|
| |
DiGiTAL.SkReAM
Posts: 1170
Score: 7
Joined: 9/6/2005
From: Florida, USA
Status: offline
|
This can obviously be used as a function or subroutine in another larger script very easily. '========================================================================== ' ' NAME: DetectOS.vbs ' ' AUTHOR: DiGiTAL.SkReAM ' DATE : 10/26/2005 ' ' COMMENT: Populates the sOS string variable with the name of the current OS ' '========================================================================== Option Explicit Dim oShell Dim oShellExec, oStdOutputText, sText, iElement, aOS, sOS Set oShell = CreateObject("Wscript.Shell") Set oShellExec = oShell.Exec("%comspec% /c ver") Set oStdOutputText = oShellExec.StdOut Do While Not oStdOutputText.AtEndOfStream sText = oStdOutputText.ReadLine aOS = Array("Windows 95", "Windows 98", "Windows NT", "Windows 2000", "Windows XP", "Microsoft Windows [Version") For iElement = LBound(aOS) To UBound(aOS) If InStr(sText, aOS(iElement)) <> 0 Then If aOS(iElement) = "Microsoft Windows [Version" Then sOS = "Windows 2003" Else sOS = aOS(iElement) End If End If Next Loop WScript.Echo sOS
_____________________________
"Would you like to touch my monkey?" - Dieter (Mike Meyers) "It is better to die like a tiger, than to live like a pussy." -Master Wong, from Balls of Fury
|
|
| |
|
|
|
 |
RE: Short, Easy way to determine OS - 11/29/2005 12:21:47 AM
|
|
 |
|
| |
mbouchard
Posts: 1894
Score: 14
Joined: 5/15/2003
From: USA
Status: offline
|
Interesting, I use something similar http://www.visualbasicscript.com/m_25374/tm.htm but didn't think of using an array.
_____________________________
Mike For useful Scripting links see the Read Me First stickey! Always remember Search is your friend.
|
|
| |
|
|
|
 |
RE: Short, Easy way to determine OS - 11/29/2005 12:33:33 AM
|
|
 |
|
| |
DiGiTAL.SkReAM
Posts: 1170
Score: 7
Joined: 9/6/2005
From: Florida, USA
Status: offline
|
Thanks. I'm currently in my array-happy phase, so am using them (arrays) heavily in almost everything.
_____________________________
"Would you like to touch my monkey?" - Dieter (Mike Meyers) "It is better to die like a tiger, than to live like a pussy." -Master Wong, from Balls of Fury
|
|
| |
|
|
|
|
|