JSchmitt Posted January 26, 2007 Posted January 26, 2007 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
Zedna Posted January 26, 2007 Posted January 26, 2007 I'm not expert on Domains and such but much usefull informations can be retrieved by WMILook at MSDNand search for WMI at this forum ... Resources UDF ResourcesEx UDF AutoIt Forum Search
PerryRaptor Posted January 26, 2007 Posted January 26, 2007 Macro @computername or if you prefer, the command prompt:> hostname
JSchmitt Posted January 26, 2007 Author Posted January 26, 2007 @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
lod3n Posted January 26, 2007 Posted January 26, 2007 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]
JSchmitt Posted January 27, 2007 Author Posted January 27, 2007 Thank you lod3n! That works fine! Did you know, if that also works with an Windows NT4 domain? Best regards Jochen
lod3n Posted January 27, 2007 Posted January 27, 2007 It ought to, but I haven't tried it on one. [font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]
lod3n Posted January 27, 2007 Posted January 27, 2007 You should compare the output of the UDF, with this too - it might be producing the same result:Opt("ExpandEnvStrings", 1) ConsoleWrite(EnvGet("USERDOMAIN") & @crlf) [font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]
JSchmitt Posted January 28, 2007 Author Posted January 28, 2007 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
lod3n Posted February 2, 2007 Posted February 2, 2007 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/288358According 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]
Valiante Posted February 22, 2012 Posted February 22, 2012 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)
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now