Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Obtaining workgourp/domain name

Status
Not open for further replies.

brianashman

Technical User
Dec 11, 2003
15
US
Is it possible to find out whether a machine is in a workgroup or domain & then name of the workgroup or domain by VBS?

The script doesn't need to look at remote machines, just the local machine the script is running on.
 
Hello brainashman,

Retrieve the Domain and DomainRole properties from win32_computersystem.
Code:
strComputer="."
set svc=GetObject("winmgmts:" _
	& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
set cCS=svc.ExecQuery _
	("select Domain,DomainRole from Win32_ComputerSystem")
for each oCS in cCS
	iDR=oCS.DomainRole
	sDN=oCS.Domain
next
if not IsNull(iDR) then wscript.echo iDR & vbcrlf & sDN
When the box belongs to a domain, sDN would be the domain name, else its workgroup name. Check out the documentation to decipher DomainRole.


regards - tsuji
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top