If you want to look up registry key database to fetch computer name/domain name, then this post helps you find the key that has this information.
- Open registry editor with the command
- Navigate to the node
- On the right side pane, look for the value
ComputerName. This would show you the computer name.
This key shows computer name in all Windows versions – Windows 7, 8 and 10.
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ComputerName\ActiveComputerName also has a key with the same name
Computername which stores the active computer name.
To explain the difference between these two registry keys, suppose the machine name is mypc1. At this point both the registry keys point to mypc1. Suppose I change the computer name to mypc2 from UI. Now the key ComputerName points to mypc2 where as the parameter in ActiveComputername still has the old name mypc1. After rebooting the computer, both the keys point to the new name mypc2.
How to get full computer name from registry key?
Looks like there is no registry key that stores full computer name. Computer name and domain name are stored separately. You can query both these registry key values and then combine them to get the full computer name. Let’s see how to retrieve these values from registry keys.
To retrieve computer name from registry
Reg query HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ComputerName /v computername
You can get computer name from TCPIP registry keys also.
Reg query HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\TcpipParameters /v Hostname
Domain name registry key:
Domain name is stored in the following registry key
Domain under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\TcpipParameters
Command to retrieve domain name from registry from CLI:
Reg query HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\TcpipParameters /v Domain