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