Is there a way to find the fully qualified domain name of a Windows XP box?
Being unfamiliar with Windows I would describe what I'm looking for as the equivalent of the command hostname --fqdn
available in Linux.
Is there a way to find the fully qualified domain name of a Windows XP box?
Being unfamiliar with Windows I would describe what I'm looking for as the equivalent of the command hostname --fqdn
available in Linux.
There is no such option to the
hostname
command in windows. However, this should do the trick:Or you can grep (under Windows:
find /I "string"
) for Host- and Domain fromset
orsysteminfo
oripconfig -all
name and glue it together elsewhere.Edit: fixed Typo. Thanks Benoit
Update: The variable
%USERDNSDOMAIN%
is only available when logged on to a domain... The DNS suffix you get from a DHCP server is not put into a environment variable (as far as I could figure out).You can find it in the system properties ("Computer name" tab).
With the command line, you can run
IPCONFIG /ALL
and have a look at the "Host name" and "Primary DNS suffix" fields.The command is:
vbscript :
DOS BATCH FILE TO CALL ABOVE SCRIPT :
Try this from the command prompt:
remember to use double
%
for%i
if using this in a batchfile. e.g.%%i
A reason you may want to do it this way is: if your users and computers are in different domains, the
%USERDNSDOMAIN%
will not be correct when applied to your computer. If you only have one domain and no child domains, then you can use the other solutions above if you like.This will also work and does not have the delay of systeminfo:
Another version:
If you need to port Unix shell scripts to windows or just like to work on the CLI, have a look at GNUwin32. It provides the common tools like cut, grep, etc for Windows.
Here is a CMD script for this:
use 'hostname' and combine with for /F "tokens=3" %%I in ('reg query "HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters" /v Domain') do set _MyDomain=%%I