Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Get os version

44 views
Skip to first unread message

Shane Newsom

unread,
Jun 26, 2001, 2:39:48 PM6/26/01
to
How can I get the version of the OS a person is using? Thanks for anyone
that can help.

--


Shane D. Newsom
System Analyst
12712 Park Central Place
Mailstop 5002 PCLR-276
Dallas, TX 75251
Phone - (972) 591-6584
Fax - (972) 531-6584


Greg Burns

unread,
Jun 26, 2001, 3:19:19 PM6/26/01
to
Function GetOS()
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Determines OS by reading reg val & comparing to known values
' OS type returned as:
' "Win95A", "Win95B", "Win98", "Win98SE", "WinME"
' "WinNT4-Wrkstat", "WinNT4-Srvr", "WinNT4-Srvr-DC"
' "Win2K-Wrkstat", "Win2K-Srvr"
'
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim oFSO, oShell
Const sModule = "getOS"

Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oShell = CreateObject("Wscript.Shell")


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"
Dim sTmp
sTmp = oShell.RegRead(_
"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control" & _
"\ProductOptions\ProductType")
If sTmp = "WinNT" Then
sTmp = "-Wrkstat"
sOStype = sOStype & sTmp
ElseIf sTmp = "ServerNT" Then
sTmp = "-Srvr"
sOStype = sOStype & sTmp
Else
GetOS = "Unknown Win2K"
' Could not pinpoint exact Win2K type
Exit Function ' >>>
End If
Else
Select Case sOStype
Case "4.00.950"
sOStype = "Win95A"
Case "4.00.1111"
Dim sSubVersion
sSubVersion = oShell.RegRead(_
"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows" & _
"\CurrentVersion\SubVersionNumber")
Select Case sSubVersion
Case " B"
sOStype = "Win95B"
Case " C"
sOStype = "Win95C"
Case Else
sOStype = "Win95X"
End Select
Case "4.03.1214"
sOStype = "Win95B"
Case "4.10.1998"
sOStype = "Win98"
Case "4.10.2222"
sOStype = "Win98SE"
Case "4.90.3000"
sOStype = "WinME" ' Windows Me
Case Else
sOstype = "?"
'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
' --- CleanUp
Set oFSO = Nothing
Set oShell = Nothing
End Function

Greg

"Shane Newsom" <sne...@jcpenney.com> wrote in message
news:19F6F4DB19AE14BC.1D2C2DD7...@lp.airnews.net...

shane newsom

unread,
Jun 26, 2001, 3:35:10 PM6/26/01
to
Thanks, for the help

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

0 new messages