JSI Tip 10093. How can I return the NetBIOS domain name, using standard commands?

Jerold Schulman

January 25, 2006

1 Min Read
ITPro Today logo in a gray background | ITPro Today

Using standard commands, I have scripted NetBiosDomain.bat to return the NetBIOS domain name.

The syntax for using NetBiosDomain.bat is:

[Call} NetBiosDomain DomainName

Where DomainName is a call directed environment variable that will contain the the NetBIOS domain name, or the computer name if the computer is not logged onto a domain, or NONE if there is an error.

NetBiosDomain.bat contains:

@echo offif {%1}=={} @echo Syntax: NetBiosDomain DomainName&goto :EOFif exist "%TEMP%NetBiosDomain.vbs" goto doit@echo dim WshNetwork, strDomainName>"%TEMP%NetBiosDomain.vbs"@echo Set WshNetwork = WScript.CreateObject("WScript.Network")>>"%TEMP%NetBiosDomain.vbs"@echo strDomainName = WshNetwork.UserDomain>>"%TEMP%NetBiosDomain.vbs"@echo Wscript.Echo WshNetwork.UserDomain>>"%TEMP%NetBiosDomain.vbs":doitSET %1=NONEFOR /F "TOKENS=*" %%D in ('cscript //nologo "%TEMP%NetBiosDomain.vbs"') do ( SET %1=%%D)



Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like