
Information please on SYSINFO
Branimir posted this file here a while back. Wouldn't be that hard to add WinMe.
'==========================================================================
' NAME: OSinfo-CLS.vbs
'
' AUTHOR: Branimir Petrovic , CPAS Systems Inc.
' DATE : 3/13/2000
'
' COMMENT: Class designed to returns OS type
' and Windows Desktop Update status
'
' METHODS:
' objOS.GetOS returns one of these strings
' "Win95A", "Win95B", "Win98", "Win98SE"
' "WinNT4-Wrkstat", "WinNT4-Srvr", "WinNT4-Srvr-DC"
' "Win2K"
' objOS.GetWDU returns TRUE if Winows Desktop Update is installed
'
'
' EXAMPLE:
' Dim objOS
' Set objOS = new OSinfo
' MsgBox "OS = " & objOS.GetOS & vbCrLf & "Windows Desktop Update = " & objOS.GetWDU
'==========================================================================
Option Explicit
' *************************************************************************
Class OSinfo
Private oFSO, oShell
' =====
Private Sub Class_Initialize
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oShell = CreateObject("Wscript.Shell")
End Sub
' =====
Private Sub Class_Terminate
Set oFSO = Nothing
Set oFSO = Nothing
End Sub
' =====
Public Function GetOS()
'Description: Determine OS by reading reg val & comparing to known values
Dim sModule
sModule = "GetOS"
Dim sOStype, sOSversion
On Error Resume Next
sOStype = oShell.RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ProductOptions\ProductType")
If Err.Number<>0 Then ' Hex(Err.Number)="80070002" - Could not find this key, OS must be Win9x
Err.Clear
sOStype = oShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\VersionNumber")
If Err.Number<>0 Then
GetOS = "Unknown Win9x" ' Could not pinpoint exact Win9x type
Exit Function ' >>>
End If
End If
If sOStype = "LanmanNT" OR sOStype = "ServerNT" OR sOStype = "WinNT" Then
Err.Clear
sOSversion = oShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\CurrentVersion")
If Err.Number<>0 Then
GetOS = "Unknown NTx" ' Could not determine NT version
Exit Function ' >>>
End If
End If
If sOSversion = "4.0" Then
Select Case sOStype
Case "LanmanNT"
sOStype = "WinNT4-Srvr-DC" ' From HKLM\SYSTEM\CurrentControlSet\Control\ProductOptions\ProductType
Case "ServerNT"
sOStype = "WinNT4-Srvr" ' From HKLM\SYSTEM\CurrentControlSet\Control\ProductOptions\ProductType
Case "WinNT"
sOStype = "WinNT4-Wrkstat" ' From HKLM\SYSTEM\CurrentControlSet\Control\ProductOptions\ProductType
End Select
ElseIf sOSversion = "5.0" Then
sOStype = "Win2K"
Else
Select Case sOStype
Case "4.00.950"
sOStype = "Win95A"
Case "4.00.1111"
sOStype = "Win95B"
Case "4.03.1214"
sOStype = "Win95B"
Case "4.10.1998"
sOStype = "Win98"
Case "4.10.2222"
sOStype = "Win98SE"
Case Else
MsgBox "sOStype = " & sOStype & vbCrLf & "Could not recognize this particular OS. Please contact your system administrator.", vbCritical, "Error in module: " & sModule
End Select
End If
GetOS = sOStype
End Function
' =====
Public Function GetWDU()
Dim oSysFldr, sSysPath, sFileVer, arVerNums
Const csSystemFolder = 1
Const csShell = "shell32.dll"
Set oSysFldr = oFSO.GetSpecialFolder (csSystemFolder)
sSysPath = oSysFldr.Path
sFileVer = oFSO.GetFileVersion(oFSO.BuildPath (sSysPath,csShell))
arVerNums = Split(sFileVer,".")
If Eval(CInt(arVerNums(0)) = 4) AND Eval(CInt(arVerNums(1)) => 71) Then
GetWDU = TRUE
ElseIf Eval(CInt(arVerNums(0)) > 4) Then
GetWDU = TRUE
Else
GetWDU = FALSE
End If
'MsgBox sFileVer
Set oSysFldr = Nothing
End Function
End Class
' *************************************************************************
--
Mark L. Ferguson Reply Only in Newsgroup
marfer's notes for OE 5.0 > http://www.geocities.com/marfer_mvp/IE_ng_notes.htm
Quote:
> I've come across the code snippet below as a method of determining the OS
> and version.
> SYSINFO is not a valid object on my system. What is required to get it
> working? Thank you.
> Set WSHShell = WScript.CreateObject("WScript.Shell")
> set objSysInfo = Wscript.CreateObject("SYSINFO.Sysinfo")
> wscript.echo objSysInfo.OSBuild
> wscript.echo objSysInfo.OSPlatform
> wscript.echo objSysInfo.OSVersion