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

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 off
if \{%1\}==\{\} @echo Syntax: NetBiosDomain DomainName&goto :EOF
if 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"
FOR /F "TOKENS=*" %%D in ('cscript //nologo "%TEMP%\NetBiosDomain.vbs"') do (
 SET %1=%%D

Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.