I have scripted DomainRole.bat to determine which of the following roles describes the current computer:

Standalone Workstation
Member Workstation
Standalone Server
Member Server
Backup Domain Controller
Primary Domain Controller
The syntax for using DomainRole.bat is:

call DomainRole string

Where string is a call directed environment variable that will contain one of the following number-text strings:

0-Standalone Workstation
1-Member Workstation
2-Standalone Server
3-Member Server
4-Backup Domain Controller
5-Primary Domain Controller
DomainRole.bat contains:
@echo off
if \{%1\}==\{\} @echo Syntax: DomainRole Role&goto :EOF
if exist "%TEMP%\DoomainRole.vbs" goto doit
@echo On Error Resume Next>"%TEMP%\DoomainRole.vbs"
@echo strComputer = ".">>"%TEMP%\DoomainRole.vbs"
@echo Set objWMIService = GetObject("winmgmts:\\" ^& strComputer ^& "\root\cimv2")>>"%TEMP%\DoomainRole.vbs"
@echo Set colItems = objWMIService.ExecQuery("Select DomainRole from Win32_ComputerSystem",,48)>>"%TEMP%\DoomainRole.vbs"
@echo For Each objItem in colItems>>"%TEMP%\DoomainRole.vbs"
@echo.  Wscript.Echo objItem.DomainRole>>"%TEMP%\DoomainRole.vbs"
@echo Next>>"%TEMP%\DoomainRole.vbs"
for /f "Tokens=*" %%r in ('cscript //nologo "%TEMP%\DoomainRole.vbs"') do (
 set /a role=1%%r -10
set /a role=%role% * 28
<font size="1">set table=0-Standalone Workstation    1-Member Workstation        2-Standalone Server         3-Member Server             4-Backup Domain Controller  5-Primary Domain Controller #</font>
call set work=%%table:~%role%^,28%%#
set work=%work:  =%
set work=%work: #=%
set work=%work:#=%
endlocal&set %1=%work%