How do I differentiate between NT Workstation and NT Server 
Author Message
 How do I differentiate between NT Workstation and NT Server

Anyone know if there is a way to tell whether the machine is running NT
Server or NT Workstation via some object or method?

Thanks.



Sat, 29 Jun 2002 03:00:00 GMT  
 How do I differentiate between NT Workstation and NT Server
The script below will return the OS for all Win9x (?, there may be some
95b strings I haven't found yet)& NT40 boxes, won't handle W2k but it
could if you know the correct string to check for.  It also determines
if server is DC.  I took most of it from a script on Clarence's site,
unfortunately I can't credit the author at the moment.  HTH.

'Function: GetOS
'Description: Determine OS by reading reg val & comparing to known
values

Function GetOS()
Dim osShell, strOS
On Error Resume Next
Err.Clear

Set OsShell = CreateObject("Wscript.Shell")
strOS =
OsShell.RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ProductOptions\ProductType")

  If Hex(err)="80070002" Then
    Err.Clear
        strOS =
OsShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\VersionNumber")

                If err<> 0 Then
                        GetOS = Null
                        Exit Function
                End if
  End If

Select Case strOS
        Case "LanmanNT"
                strOpSystem = "NT4DC"

        Case "ServerNT"
                strOpSystem = "NT4SRVR"

        Case "WinNT"
                strOpSystem = "NT4WS"

        Case "4.00.950"
                strOpSystem = "Win95A"

        Case "4.00.1111"
                strOpsystem = "Win95B"

        Case "4.03.1214"
                strOpSystem = "Win95B"

        Case "4.10.1998"
                strOpSystem = "Win98"

        Case "4.10.2222"
                strOpSystem = "Win98SE"

        Case Else
                MsgBox "Error determing the OS.  Please contact " & strSysAdmin1 & "or
" & strSysAdmin2 & "." & vbcrlf & _
                                                "after recording this error message exactly."

 End Select

Set osShell = Nothing
End Function

Quote:

> Anyone know if there is a way to tell whether the machine is running NT
> Server or NT Workstation via some object or method?

> Thanks.



Sat, 29 Jun 2002 03:00:00 GMT  
 How do I differentiate between NT Workstation and NT Server
The script is missing a line...it needs to have this before the "End
Function" statement:    (...or am I missing something??)

GetOS = strOpSystem

- Greg


Quote:
> The script below will return the OS for all Win9x (?, there may be some
> 95b strings I haven't found yet)& NT40 boxes, won't handle W2k but it
> could if you know the correct string to check for.  It also determines
> if server is DC.  I took most of it from a script on Clarence's site,
> unfortunately I can't credit the author at the moment.  HTH.

> 'Function: GetOS
> 'Description: Determine OS by reading reg val & comparing to known
> values

> Function GetOS()
> Dim osShell, strOS
> On Error Resume Next
> Err.Clear

> Set OsShell = CreateObject("Wscript.Shell")
> strOS =

OsShell.RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Product
Options\ProductType")
Quote:

>   If Hex(err)="80070002" Then
>     Err.Clear
> strOS =

OsShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersio
n\VersionNumber")

- Show quoted text -

Quote:

> If err<> 0 Then
> GetOS = Null
> Exit Function
> End if
>   End If

> Select Case strOS
> Case "LanmanNT"
> strOpSystem = "NT4DC"

> Case "ServerNT"
> strOpSystem = "NT4SRVR"

> Case "WinNT"
> strOpSystem = "NT4WS"

> Case "4.00.950"
> strOpSystem = "Win95A"

> Case "4.00.1111"
> strOpsystem = "Win95B"

> Case "4.03.1214"
> strOpSystem = "Win95B"

> Case "4.10.1998"
> strOpSystem = "Win98"

> Case "4.10.2222"
> strOpSystem = "Win98SE"

> Case Else
> MsgBox "Error determing the OS.  Please contact " & strSysAdmin1 & "or
> " & strSysAdmin2 & "." & vbcrlf & _
> "after recording this error message exactly."

>  End Select

> Set osShell = Nothing
> End Function


> > Anyone know if there is a way to tell whether the machine is running NT
> > Server or NT Workstation via some object or method?

> > Thanks.



Sat, 06 Jul 2002 03:00:00 GMT  
 How do I differentiate between NT Workstation and NT Server
Hmmmm... having looked at it again I see the inconsistency, here's the
explanation as I remember it.  Short answer: you need to Dim strOpSystem
outside of the function and refer to it to get the OS value.

Long Answer:  Since I use the Operating System value several times in my
script I don't want to rerun the GetOS function each time I need the
value. Once I figured out this was happening I just Dim'd strOpSystem
outside of the function & refer to it when I need the value.  What I
probably should have also done is change the function to a Sub to be
clear that GetOS isn't returning a value.

Thanks for pointing it out, I'm still learning.....

Quote:

> The script is missing a line...it needs to have this before the "End
> Function" statement:    (...or am I missing something??)

> GetOS = strOpSystem

> - Greg



> > The script below will return the OS for all Win9x (?, there may be some
> > 95b strings I haven't found yet)& NT40 boxes, won't handle W2k but it
> > could if you know the correct string to check for.  It also determines
> > if server is DC.  I took most of it from a script on Clarence's site,
> > unfortunately I can't credit the author at the moment.  HTH.

> > 'Function: GetOS
> > 'Description: Determine OS by reading reg val & comparing to known
> > values

> > Function GetOS()
> > Dim osShell, strOS
> > On Error Resume Next
> > Err.Clear

> > Set OsShell = CreateObject("Wscript.Shell")
> > strOS =

> OsShell.RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Product
> Options\ProductType")

> >   If Hex(err)="80070002" Then
> >     Err.Clear
> > strOS =

> OsShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersio
> n\VersionNumber")

> > If err<> 0 Then
> > GetOS = Null
> > Exit Function
> > End if
> >   End If

> > Select Case strOS
> > Case "LanmanNT"
> > strOpSystem = "NT4DC"

> > Case "ServerNT"
> > strOpSystem = "NT4SRVR"

> > Case "WinNT"
> > strOpSystem = "NT4WS"

> > Case "4.00.950"
> > strOpSystem = "Win95A"

> > Case "4.00.1111"
> > strOpsystem = "Win95B"

> > Case "4.03.1214"
> > strOpSystem = "Win95B"

> > Case "4.10.1998"
> > strOpSystem = "Win98"

> > Case "4.10.2222"
> > strOpSystem = "Win98SE"

> > Case Else
> > MsgBox "Error determing the OS.  Please contact " & strSysAdmin1 & "or
> > " & strSysAdmin2 & "." & vbcrlf & _
> > "after recording this error message exactly."

> >  End Select

> > Set osShell = Nothing
> > End Function


> > > Anyone know if there is a way to tell whether the machine is running NT
> > > Server or NT Workstation via some object or method?

> > > Thanks.



Sat, 06 Jul 2002 03:00:00 GMT  
 How do I differentiate between NT Workstation and NT Server
Looks like a slightly modified version of mine. Glad someone can make
use of it.

Cheers,

Nick.

Quote:
> -----Original Message-----

> Posted At: 11 January 2000 23:30
> Posted To: microsoft.public.scripting.wsh
> Conversation: How do I differentiate between NT Workstation and NT
> Server
> Subject: Re: How do I differentiate between NT Workstation
> and NT Server

> The script below will return the OS for all Win9x (?, there
> may be some
> 95b strings I haven't found yet)& NT40 boxes, won't handle W2k but it
> could if you know the correct string to check for.  It also determines
> if server is DC.  I took most of it from a script on Clarence's site,
> unfortunately I can't credit the author at the moment.  HTH.

> 'Function: GetOS
> 'Description: Determine OS by reading reg val & comparing to known
> values

> Function GetOS()
> Dim osShell, strOS
> On Error Resume Next
> Err.Clear

> Set OsShell = CreateObject("Wscript.Shell")
> strOS =
> OsShell.RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\C
> ontrol\ProductOptions\ProductType")

>   If Hex(err)="80070002" Then
>     Err.Clear
>    strOS =
> OsShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows
> \CurrentVersion\VersionNumber")

>            If err<> 0 Then
>                    GetOS = Null
>                    Exit Function
>            End if
>   End If

> Select Case strOS
>    Case "LanmanNT"
>            strOpSystem = "NT4DC"

>    Case "ServerNT"
>            strOpSystem = "NT4SRVR"

>    Case "WinNT"
>            strOpSystem = "NT4WS"

>    Case "4.00.950"
>            strOpSystem = "Win95A"

>    Case "4.00.1111"
>            strOpsystem = "Win95B"

>    Case "4.03.1214"
>            strOpSystem = "Win95B"

>    Case "4.10.1998"
>            strOpSystem = "Win98"

>    Case "4.10.2222"
>            strOpSystem = "Win98SE"

>    Case Else
>            MsgBox "Error determing the OS.  Please contact
> " & strSysAdmin1 & "or
> " & strSysAdmin2 & "." & vbcrlf & _
>                                            "after
> recording this error message exactly."

>  End Select

> Set osShell = Nothing
> End Function


> > Anyone know if there is a way to tell whether the machine
> is running NT
> > Server or NT Workstation via some object or method?

> > Thanks.



Mon, 08 Jul 2002 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. How do I differentiate between NT Workstation and NT Server

2. Which Web Servers work with NT Workstation ?

3. detect with ADSI-NT server or workstation

4. creating a vb script to copy file accross a network to nt workstation

5. WSH ADSI -- Set user rights on NT workstations

6. Setting Lcoal Account Policies on NT 4 Workstations

7. Installng WSH on 95/nt workstations

8. Logoff a nt workstation

9. nt workstation rename via a script

10. Changing time zone on NT workstation

11. Can you install WSH on a Windows NT Workstation

12. Unlock Workstation NT with a screensaver

 

 
Powered by phpBB® Forum Software