How to get domain name in Windows using command?
Try:
echo %USERDOMAIN%
or
echo %USERDNSDOMAIN%
If that still doesn't work, you can try using systeminfo:
systeminfo | findstr /B /C:”Domain”
You can run below command on command prompt:
set user
It gives you a lot more information related to domain in addition to the name of domain as shown in below snapshot:
- User DNS Domain
- User Domain
- User Domain Roaming Profile
- User Name
- User Profile
Important Note: Domain on which your computer is registered might not be same as the domain on which the logged-in user is registered. Please read about transitivity and direction in domain trust to know how a user registered in one domain can login to a computer on another domain.