Using the Nltest.exe utility from the Support Tools on the operating system CD-ROM, I have scripted GetPDC.bat to return the NetBIOS PDC name.

The syntax for using GetPDC.bat is:

call GetPDC PDC

Where PDC is a call directed environment variable that will contain the NetBIOS PDC name.

GetPDC.bat contains:

@echo off
if \{%1\}==\{\} @echo Syntax: call GetPDC PDC&goto :EOF
set %1=NONE
for /f "Tokens=1* Delims=\" %%a in ('nltest /DCNAME:"%USERDOMAIN%"^|FIND "PDC"') do (
 set %1=%%b