_COMPNAME — Returns the computer’s name.

Syntax:
%_COMPNAME

This variable returns the fully qualified DNS name of the computer, including the domain name if any.


echo %_compname