Find computer name from command line

You can find out your computer name from command line using hostname command.

c:\> hostname

Note that  hostname prints only the NetBios name of the computer, not the full DNS name.  It works on all Windows versions- XP, Vista, Windows 7, Server 2003 and Server 2008.

System name is also stored in the environment variable computername. We can print the computer name using this environment variable as follows.

c:\>echo  %computername%


Note that, %computername% is more convenient to use in batch files. We can straight away use %computername% wherever we want to refer the local host name.

Get DNS or FQDN(fully qualified domain name) of the computer

net config workstation | findstr /C:"Full Computer name"

Find computer name using wmic

wmic computersystem  get name