Mark said:
I need to know what registry key will accurately
represent what domain a MACHINE is associated to, even
when a user logs on to the machine locally.
Any help would be very much appreciated! Thank you for
your help!!!!
Hi
As far as I know, there is no "safe" place in registry to read this from.
Parse the output from "net.exe config workstation" in a batch file, or
use VBScript/WMI.
Batch file (do *not* remove the spaces in "workstation domain "):
'--------------------8<----------------------
@echo off
for /f "tokens=3" %%a in (
'net.exe config workstation^|find.exe /i "workstation domain "') do set domain=%%a
echo %domain%
'--------------------8<----------------------
VBScript/WMI:
'--------------------8<----------------------
sNode = "." ' use "." for local computer
Set oWMI = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & sNode & "\root\cimv2")
Set colComputer = oWMI.ExecQuery _
("Select DomainRole, Domain from Win32_ComputerSystem")
For Each oComputer in colComputer
iDR = oComputer.DomainRole
sName = oComputer.Domain
Next
If iDR = 0 Or iDR = 2 Then
WScript.Echo "Computer is in workgroup " & sName
Else
WScript.Echo "Computer is in domain " & sName
End If
'--------------------8<----------------------