Sign in to follow this  
Followers 0
JSchmitt

Get NetBIOS Domain of the computer

11 posts in this topic

Hello,

I would like to get the NETBIOS Domain of the computer the script is running on.

There´s no problem to get the Domain of the logged on user, but the computer

domain might be different.

Does anyone got an suggestion, how to get this value?

Thanx in advance for any suggestions!

Jochen

Share this post


Link to post
Share on other sites



Macro @computername

or if you prefer, the command prompt:> hostname

Share this post


Link to post
Share on other sites

@Zedna: WMI wolud retrieve the FQDN AFAIK

@PerryRaptor: I would like to retrieve the NetBIOS Domain name of my computer and not only the name of my computer

Thanx in advance

Jochen

Share this post


Link to post
Share on other sites

Try this UDF:

Func _GetNetBIOSDomain()
    local $objRootDSE = ObjGet("LDAP://RootDSE")
    local $strDNSDomain = $objRootDSE.Get("defaultNamingContext")
    local $objTrans = ObjCreate("NameTranslate")
    $objTrans.Init(3, "") ; 3 = ADS_NAME_INITTYPE_GC
    $objTrans.Set(1, $strDNSDomain) ; 1=ADS_NAME_TYPE_1779
    local $strNetBIOSDomain = $objTrans.Get(3) ; 3=ADS_NAME_TYPE_NT4
    return StringLeft($strNetBIOSDomain, StringLen($strNetBIOSDomain) - 1)
EndFunc

ConsoleWrite("NetBIOS Domain Name: " & _GetNetBIOSDomain() & @CRLF)

[font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]

Share this post


Link to post
Share on other sites

Thank you lod3n!

That works fine!

Did you know, if that also works with an Windows NT4 domain?

Best regards

Jochen

Share this post


Link to post
Share on other sites

Hallo lod3n,

now I can test it only in a single domain environment.

I posted that i would like to retrieve the computer domain name and not the userdomain.

Does your script does this?

If i would like to retrieve the userdomain, i can have a look the the registry.

Thanks in advance

Jochen

Share this post


Link to post
Share on other sites

Ah, sorry about that. What you are asking for (now I understand) is exceedingly easy:

$objWinNTSysInfo = ObjCreate("WinNTSystemInfo")
ConsoleWrite($objWinNTSysInfo.DomainName & @crlf)

This will work on Windows 2000 or above, or NT with DSClient installed:

http://support.microsoft.com/kb/288358

According to that article, possibly also Win98, but I'm not sure, and can't test that.


[font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]

Share this post


Link to post
Share on other sites

Sorry for dragging up such an old thread, but that didn't work for me. When running as a user other than the logged in user, the above still returns the user domain, not the Computer domain. Here's some very simple AutoIt code which will return the Computer domain;

$objSystemInfo = ObjCreate("ADSystemInfo")
$domain = $objSystemInfo.DomainShortName
MsgBox(0, "Domain", $domain)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0