workgroup or domain

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
 
T

Torgeir Bakken \(MVP\)

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

Torgeir Bakken \(MVP\)

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top