Windows equivalent of hostname variable

I needed to get the network name of a computer through an environment variable. The “hostname” command gives this information, but it’s not a system variable. The proper system variable for the dns name of a computer is %COMPUTERNAME%. That was easy!