Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Short, Easy way to determine OS

 
Logged in as: Guest
arrSession:exec spGetSession 2,16,28386
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> Post a VBScript >> Short, Easy way to determine OS
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 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
 
 
Post #: 1
 
 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.

(in reply to DiGiTAL.SkReAM)
 
 
Post #: 2
 
 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

(in reply to mbouchard)
 
 
Post #: 3
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> Post a VBScript >> Short, Easy way to determine OS Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts