Does anyone know of a way to identify that the PC being logged on to is a Windows NT 4.0 server? We have VB scripts that we do not want running at logon whenever the PC is a Windows NT (or Windows 2000) server. Is there something in the registry, for example that can be read that will identify the PC as a server

Russell-S

Re: Identifying Platform at logon by Marty

Marty
Thu Apr 29 12:07:29 CDT 2004


"Russell-S" <anonymous@discussions.microsoft.com> wrote in message
news:FD7A9623-B23D-46A6-B3D6-EDF589E956C3@microsoft.com...
> Does anyone know of a way to identify that the PC being logged on to is a
Windows NT 4.0 server? We have VB scripts that we do not want running at
logon whenever the PC is a Windows NT (or Windows 2000) server. Is there
something in the registry, for example that can be read that will identify
the PC as a server?
>
> Russell-S


I think you could get the product type through WMI, but I can't remember for
sure.

You could read this registry value:

Key: "HKLM\System\CurrentControlSet\Control\ProductOptions"
ValueName: "ProductType" (REG_SZ)

If this value is "ServerNT" it is a standalone server or member server.
If this value is "LanmanNT" then it is a domain controller

This may not work for you if the script is running from a Terminal Server or
Citrix session. In that case you could also check some environment
variables:

Pseudo code (adapted from a KiXtart logon script):

Select
Case Platform = WindowsNT
ResultCode =
ReadValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\ProductOption
s", "ProductType")
If ResultCode = "ServerNT" Or ResultCode = "LanmanNT"
Select
Case "%WINSTATIONNAME%" <> "" And "%WINSTATIONNAME%" <> "CONSOLE"
' This is a Citrix session:
ProductType = "Workstation-Terminal"
Case "%SESSIONNAME%" <> "" And "%SESSIONNAME%" <> "CONSOLE"
' This is a terminal session:
ProductType = "Workstation-Terminal"
Case Else
' This is an NT server interactive login:
ProductType = "Server"
End Select
Else
ProductType = "Workstation"
EndIf

Case Platform = Windows9x
ProductType = "Workstation"

Case Else
' Failed to determine the operating system

End Select




Re: Identifying Platform at logon by Richard

Richard
Thu Apr 29 12:07:14 CDT 2004

Russell-S wrote:

> Does anyone know of a way to identify that the PC being logged on to is a
Windows NT 4.0 server? We have VB scripts that we do not want running at
logon whenever the PC is a Windows NT (or Windows 2000) server. Is there
something in the registry, for example that can be read that will identify
the PC as a server?

Hi,

If all computers have WMI (comes with W2k and can be installed on NT), the
code below determines the computer role:

' Specify local computer
strComputer = "."

' Trap error if WMI not installed.
On Error Resume Next
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
If Err.Number <> 0 Then
On Error GoTo 0
Wscript.Echo "WMI not installed"
Else
Set colComputers = objWMIService.ExecQuery _
("SELECT * FROM Win32_ComputerSystem")
If Err.Number <> 0 Then
On Error GoTo 0
Wscript.Echo "Win32_ComputerSystem class not supported"
Else
On Error GoTo 0
For Each objComputer In colComputers
intRole = objComputer.DomainRole
Select Case intRole
Case 0
strRole = "standalone workstation"
Case 1
strRole = "member workstation"
Case 2
strRole = "standalone server"
Case 3
strRole = "member server"
Case 4
strRole = "backup domain controller"
Case 5
strRole = "primary domain controller"
End Select
Wscript.Echo "Computer is a " & strRole
Next
End If
End If

--
Richard
Microsoft MVP Scripting and ADSI
HilltopLab web site - http://www.rlmueller.net
--



Re: Identifying Platform at logon by anonymous

anonymous
Thu Apr 29 13:36:02 CDT 2004

Thank you Richard and Marty. I was looking for something in the registry. The HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\ProductOptions\ProductType will help

Russell-S