From: Yeming on
hello,

I need a vbs snippet which can get the netbios name of current domain before
user logon.

the below snippet can't work since user is not logon:

Set oWshNetwork = WScript.CreateObject("WScript.Network")
stDomainName =oWshNetWork.userDomain

how to achieve the function by other way ?

--




From: Richard Mueller on
Yeming wrote:

> I need a vbs snippet which can get the netbios name of current domain
> before user logon.
>
> the below snippet can't work since user is not logon:
>
> Set oWshNetwork = WScript.CreateObject("WScript.Network")
> stDomainName =oWshNetWork.userDomain
>
> how to achieve the function by other way ?

Perhaps you can use the ADSystemInfo object:

Set objSysInfo = CreateObject("ADSystemInfo")
strNetBIOSDomain = objSysInfo.DomainShortName

If that doesn't work, I would try to retrieve the USERDOMAIN environment
variable:

Set objShell = CreateObject("Wscript.Shell")
strNetBIOSDomain = objShell.Environment("Process").Item("USERDOMAIN")

Finally, you can retrieve the DNS name of the domain from the RootDSE
object, then use the NameTranslate object to convert this to the NetBIOS
name. For details, see this link:

http://www.rlmueller.net/NameTranslateFAQ.htm#How%20do%20I%20find%20the%20NetBIOS%20name%20of%20the%20domain

--
Richard
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net