workgroup or domain

  • Thread starter Thread starter Charles P. Lamb
  • Start date Start date
C

Charles P. Lamb

Where is the status of a computer as member of a workgroup or domain
stored. I'm guessing its somewhere in the registry but I haven't been
able to figure out where yet.

Thanks,

Charles P. Lamb
 
Charles said:
Where is the status of a computer as member of a workgroup or domain
stored. I'm guessing its somewhere in the registry but I haven't been
able to figure out where yet.
Hi

As far as I know, you will not find that information in registry.

Here is a vbscript function that uses WMI to obtain this information:


'--------------------8<----------------------
sComputer = "." ' use "." for local computer

If IsDomainMember(sComputer) Then
WScript.Echo "Domain member"
Else
WScript.Echo "Workgroup member"
End if

Function IsDomainMember(Node)
' Returns True or False based on Win32_ComputerSystem.DomainRole
'
Set oWMI = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & Node & "\root\cimv2")
Set colComputer = oWMI.ExecQuery _
("Select DomainRole from Win32_ComputerSystem")
For Each oComputer in colComputer
iDR = oComputer.DomainRole
Next

If iDR = 0 Or iDR = 2 Then
IsDomainMember = False
Else
IsDomainMember = True
End If
End Function
'--------------------8<----------------------
 
Charles said:
Where is the status of a computer as member of a workgroup or domain
stored. I'm guessing its somewhere in the registry but I haven't been
able to figure out where yet.
Hi

As far as I know, you will not find that information in registry.

Here is a vbscript function that uses WMI to obtain this information:


'--------------------8<----------------------
sComputer = "." ' use "." for local computer

If IsDomainMember(sComputer) Then
WScript.Echo "Domain member"
Else
WScript.Echo "Workgroup member"
End if

Function IsDomainMember(Node)
' Returns True or False based on Win32_ComputerSystem.DomainRole
'
Set oWMI = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & Node & "\root\cimv2")
Set colComputer = oWMI.ExecQuery _
("Select DomainRole from Win32_ComputerSystem")
For Each oComputer in colComputer
iDR = oComputer.DomainRole
Next

If iDR = 0 Or iDR = 2 Then
IsDomainMember = False
Else
IsDomainMember = True
End If
End Function
'--------------------8<----------------------
 
Back
Top