Display the host name portion of the full computer name of the computer.
Syntax HOSTNAME Options /? Display Help
The hostname command is only available if the Internet Protocol (TCP/IP) is installed as a network component.
The computer hostname is usually (but not always) the same as the %COMPUTERNAME% variable.
When called with any argument other than /? hostname sets errorlevel to 1 and prints an error message.
If the environment variable _CLUSTER_NETWORK_NAME_ exists and is populated, then HOSTNAME will return the value of that variable in place of the true Hostname.
Examples
Display the system hostname:
C:\> hostname
“There's a little bit of magic in everything, and some loss to even things out” ~ Lou Reed
Related:
echo %computername%
Equivalent PowerShell cmdlet: $env:COMPUTERNAME
Equivalent bash command: hostname