JSI Tip 9582. How can I use the command line to determine of a DFS root is a Domain Root or a Standalone Root?

When you use the DFS MMC snap-in, a Domain Root has an icon with two servers, and a Standalone Root has an icon with one server.

I have scripted ViewDFSRoot.bat to determine if a DFS root is a Domain Root or a Standalone Root.

The syntax for using ViewDFSRoot.bat is:

call ViewDFSRoot \\ServerName\ShareName Answer


\\ServerName\ShareName is the DFSName.

Answer                 is a call directed environment variable that will contain:
                       D  if \\ServerName\ShareName is a Domain Root.
                       S  if \\ServerName\ShareName is a Standalone Root.
                       N  if \\ServerName\ShareName is a not found.
ViewDFSRoot.bat contains:
@echo off
if \{%2\}==\{\} @echo Syntax: ViewDFSRoot DFSName Answer&goto :EOF
set ans=N
for /f "Tokens=*" %%a in ('dfsutil /root:%1 /view^|findstr "Element Domain Standalone"') do (
 set line=%%a
 if "!line:~0,18!" EQU "Element not found." set ans=N
 if "!line:~0,15!" EQU "Standalone Root" set ans=S
 if "!line:~0,11!" EQU "Domain Root" set ans=D
endlocal&set %2=%ans%

TAGS: Windows 8
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.