_DOMAINFOREST — Returns the domain’s forest name.

Syntax:
%_DOMAINFOREST

If the computer is not joined to a domain, this variable returns an empty string.


iff "%_domainforest" != "" then
   echo %computername is a member of %_domainforest
else
   echo %computername is not a member of a domain.
endiff