≡ Menu

Find computer name from command line

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

c:\> hostname
techblogger-pc

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%
WINCMD-PC

c:\>

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
4 comments… add one
  • Shahi

    net config works on win7 to get fqdn name. but it’s printing as below

    Full Computer name   mypc.mydomain.com

    how to print only fqdn and no additional text in the line? if I could do this, I can read the value to a variable in batch script.

    • HELPER

      YOU NEED TO USE FOR /F %%

  • swar

    Help Needed

    In network i want to know PC name with the help of user id to know on which machine he login into ?
    Cmd pls

  • Adi

    Please I need a Command to find the PC name with the help of user id to know on which machine he login into ?

Leave a Comment