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 strongm 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.

AntunB

IS-IT--Management
Aug 11, 2003
263
AU
how would i determine the OS???
this is for wsh 5.1

i want like 95/98/NT/XP/2000

there doesnt have to be the type like 95b

thankyou
 
wscript.echo OS()


'///////////////////////////////////////////////////////
'-------------------------------------------------------
' Determine Operating System Function
'-------------------------------------------------------
'///////////////////////////////////////////////////////


Function OS()


On Error Resume Next


OSType = ws.RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ProductOptions\ProductType")
If Err.Number<>0 Then
Err.Clear
OSType = ws.RegRead(&quot;HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\VersionNumber&quot;)
If Err.Number<>0 Then
OS = &quot;Unknown&quot;
Else
End If
Else
End If

If OSType = &quot;LanmanNT&quot; OR OSType = &quot;ServerNT&quot; OR OSType = &quot;WinNT&quot; Then
Err.Clear
OSversion = ws.RegRead(&quot;HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\CurrentVersion&quot;)
If Err.Number<>0 Then
GetOS = &quot;Unknown&quot;
Else
End If
Else
End If

If OSversion = &quot;4.0&quot; Then
Select Case OSType
Case &quot;LanmanNT&quot;
OS = &quot;Windows NT4 Server DC&quot;
Case &quot;ServerNT&quot;
OSType = &quot;Windows NT4 Server&quot;
Case &quot;WinNT&quot;
OS = &quot;Windows NT4 Workstation&quot;
End Select
ElseIf OSversion = &quot;5.0&quot; Then
Select Case OSType
Case &quot;LanmanNT&quot;
OS = &quot;Windows 2000 Server DC&quot;
Case &quot;ServerNT&quot;
OS = &quot;Windows 2000 Server&quot;
Case &quot;WinNT&quot;
OS = &quot;Windows 2000 Professional&quot;
End Select
Elseif OSversion = &quot;5.1&quot; Then
OS = &quot;Windows XP&quot;
Else
If OSType = &quot;4.00.950&quot; OR OSType = &quot;4.00.1111&quot; OR OSType = &quot;4.03.1214&quot; Then
OS = &quot;Windows 95&quot;
ElseIf OSType = &quot;4.10.1998&quot; OR OSType = &quot;4.10.2222&quot; Then
OS = &quot;Windows 98&quot;
Else
OS = &quot;Unknown&quot;
End If
End If

End Function
 
Try something like this:
Code:
Set oSh=CreateObject(&quot;WScript.Shell&quot;)
Set oEx=oSh.Exec(&quot;%COMSPEC% /C ver&quot;)
Do While oEx.Status=0
  WScript.Sleep 100
Loop
While Len(buf) < 1
 buf=Replace(oEx.StdOut.ReadLine,vbCrLf,&quot;&quot;)
Wend
WScript.Echo &quot;'&quot; & buf & &quot;'&quot;

Hope This Help
PH.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top