Vbscript / Operating System / Get Domain Name
The script below retrieves the machine domain name in the form DC=domain,DC=local and converts it to the DNS form domain.local.
Set objRootLDAP = GetObject("LDAP://RootDSE") strDomain = objRootLDAP.Get("DefaultNamingContext")
Wscript.Echo strDomain
strDomain = Replace(strDomain, ",DC=",".") strDomain = Replace(strDomain, "DC=","") Wscript.Echo strDomain
This script retrieves the domain name of the user running the script in NetBIOS format.
Set objNetwork = WScript.CreateObject("WScript.Network")strUserDomain = objNetwork.UserDomain
Wscript.Echo strUserDomain
Please note that a disclaimer applies to any code on this page.
|