Page 1 of 1 1
Topic Options
#392 - 1999-09-03 04:20 PM Detecting OS Type
Anonymous
Unregistered


How do you detect the type of OS running, ie. Win95, Win98, NT Workstation?


Top
#393 - 1999-09-03 05:04 PM Re: Detecting OS Type
Anonymous
Unregistered


Hello,

Here is a copy of code I use to detect the difference.

Regards,

Brad

$server=0
? "Determining the OS type and setting the command variable."
If @INWIN=1 ; INWIN returns a 1 if being run from Windows NT
$OS="Windows NT"
; If logging in from Windows NT, check to see if you are on a Server or a
; Workstation. The key:
; HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ProductOptions\ProductType
; has the following three possible values:
; WinNT if on a workstation
; ServerNT if on a server
; LanmanNT if on a domain controller (primary or backup)
; Right now, we are only concerned if the computer is a server. So,
$key="HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ProductOptions"
$WksType=ReadValue($key,"ProductType")
$returncode=@ERROR
If $returncode>0
? "There was an error reading: "+$key+"\ProductType"
? "The error number is: "+$returncode
Else
If (($WksType = "LanmanNT") or ($WksType = "ServerNT"))
$server=1
Endif
Endif
$comd="@LANROOT\cmd.exe /c "
Else
$key=$loc+"Microsoft\Windows\CurrentVersion\Setup"
$WinDir=ReadValue($key,"WinDir")
; Will set the OS variable to Win9x. If neccesary to check for difference between
; Win95 and Win98 later, @DOS will report 4.0 for Win95 and 4.1 for Win98
$OS="Win9x"
$comd="$WinDir\command.com /c "
Endif
? "This system is: "+$OS

Top
#394 - 1999-09-09 10:34 AM Re: Detecting OS Type
Anonymous
Unregistered


Actually, I will need to determin if it is NT server or Workstation also.

Top
#395 - 1999-09-09 01:30 PM Re: Detecting OS Type
Anonymous
Unregistered


Please ignore that, I figured it out =)

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 1343 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.149 seconds in which 0.091 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org