How to get domain name in Windows using command?
I need a similar command to Linux' domainname on Windows without using any third-party application.
Is there such a command?
windows linux windows-7
migrated from stackoverflow.com Aug 30 '12 at 12:02
This question came from our site for professional and enthusiast programmers.
add a comment |
I need a similar command to Linux' domainname on Windows without using any third-party application.
Is there such a command?
windows linux windows-7
migrated from stackoverflow.com Aug 30 '12 at 12:02
This question came from our site for professional and enthusiast programmers.
For information - domain name of computer and domain name of the logged-in user might not be same.
– RBT
Feb 11 at 9:17
add a comment |
I need a similar command to Linux' domainname on Windows without using any third-party application.
Is there such a command?
windows linux windows-7
I need a similar command to Linux' domainname on Windows without using any third-party application.
Is there such a command?
windows linux windows-7
windows linux windows-7
edited Jan 23 '15 at 13:36
Peter Mortensen
8,376166185
8,376166185
asked Aug 29 '12 at 8:45
Ricky
migrated from stackoverflow.com Aug 30 '12 at 12:02
This question came from our site for professional and enthusiast programmers.
migrated from stackoverflow.com Aug 30 '12 at 12:02
This question came from our site for professional and enthusiast programmers.
For information - domain name of computer and domain name of the logged-in user might not be same.
– RBT
Feb 11 at 9:17
add a comment |
For information - domain name of computer and domain name of the logged-in user might not be same.
– RBT
Feb 11 at 9:17
For information - domain name of computer and domain name of the logged-in user might not be same.
– RBT
Feb 11 at 9:17
For information - domain name of computer and domain name of the logged-in user might not be same.
– RBT
Feb 11 at 9:17
add a comment |
5 Answers
5
active
oldest
votes
Try:
echo %USERDOMAIN%
or
echo %USERDNSDOMAIN%
If that still doesn't work, you can try using systeminfo:
systeminfo | findstr /B /C:”Domain”
3
%Userdomain% would give the domain of the user, not necessarily same as the domain name of the computer. windows-commandline.com/find-domain-name-command-line
– Sriniv
Jan 18 '15 at 19:25
the smart quotes in”Domain”
will make it fail to grep the string
– phuclv
Feb 11 at 9:29
add a comment |
The %USERDOMAIN% and the network computer domain can be different. The systeminfo command will get the right answer but it is SLOW! Here is a solution I've used:
@REM + find the computer domain name
FOR /F "usebackq tokens=*" %%a IN (`ipconfig /all`) DO (
@((ECHO %%a | findstr /i /c:"Primary Dns Suffix") && SET _str=%%a) > NUL 2>&1
)
FOR /F "tokens=2 delims=:" %%a IN ("%_str%") do SET _computerDomain=%%a
SET _computerDomain=%_computerDomain: =%
SET _fqdn=%COMPUTERNAME%.%_computerDomain%
add a comment |
@Mike: fine solution - but I had some problems with it in a multi-language enviroment.
I have German and English servers.
I changed your script to use wmic.exe:
@REM + Find the computer domain name
@echo off
FOR /F "usebackq tokens=*" %%a IN (`wmic.exe COMPUTERSYSTEM GET DOMAIN /Value`) DO (
@((ECHO %%a | findstr /i /c:"Domain=") && SET _str=%%a) > NUL 2>&1
)
FOR /F "tokens=2 delims=^=" %%a IN ("%_str%") do SET _computerDomain=%%a
SET _computerDomain=%_computerDomain: =%
SET _fqdn=%COMPUTERNAME%.%_computerDomain%
echo %_fqdn%
Thx for your idea
add a comment |
One line is enought to get the domain using a local user:
FOR /F "usebackq tokens=2 delims==" %%a IN (
wmic.exe COMPUTERSYSTEM
) DO set _computerDom=%%a
GET DOMAIN /Value ^|find /i "domain"
add a comment |
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.
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f468217%2fhow-to-get-domain-name-in-windows-using-command%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
5 Answers
5
active
oldest
votes
5 Answers
5
active
oldest
votes
active
oldest
votes
active
oldest
votes
Try:
echo %USERDOMAIN%
or
echo %USERDNSDOMAIN%
If that still doesn't work, you can try using systeminfo:
systeminfo | findstr /B /C:”Domain”
3
%Userdomain% would give the domain of the user, not necessarily same as the domain name of the computer. windows-commandline.com/find-domain-name-command-line
– Sriniv
Jan 18 '15 at 19:25
the smart quotes in”Domain”
will make it fail to grep the string
– phuclv
Feb 11 at 9:29
add a comment |
Try:
echo %USERDOMAIN%
or
echo %USERDNSDOMAIN%
If that still doesn't work, you can try using systeminfo:
systeminfo | findstr /B /C:”Domain”
3
%Userdomain% would give the domain of the user, not necessarily same as the domain name of the computer. windows-commandline.com/find-domain-name-command-line
– Sriniv
Jan 18 '15 at 19:25
the smart quotes in”Domain”
will make it fail to grep the string
– phuclv
Feb 11 at 9:29
add a comment |
Try:
echo %USERDOMAIN%
or
echo %USERDNSDOMAIN%
If that still doesn't work, you can try using systeminfo:
systeminfo | findstr /B /C:”Domain”
Try:
echo %USERDOMAIN%
or
echo %USERDNSDOMAIN%
If that still doesn't work, you can try using systeminfo:
systeminfo | findstr /B /C:”Domain”
answered Aug 29 '12 at 8:49
Jon LinJon Lin
735818
735818
3
%Userdomain% would give the domain of the user, not necessarily same as the domain name of the computer. windows-commandline.com/find-domain-name-command-line
– Sriniv
Jan 18 '15 at 19:25
the smart quotes in”Domain”
will make it fail to grep the string
– phuclv
Feb 11 at 9:29
add a comment |
3
%Userdomain% would give the domain of the user, not necessarily same as the domain name of the computer. windows-commandline.com/find-domain-name-command-line
– Sriniv
Jan 18 '15 at 19:25
the smart quotes in”Domain”
will make it fail to grep the string
– phuclv
Feb 11 at 9:29
3
3
%Userdomain% would give the domain of the user, not necessarily same as the domain name of the computer. windows-commandline.com/find-domain-name-command-line
– Sriniv
Jan 18 '15 at 19:25
%Userdomain% would give the domain of the user, not necessarily same as the domain name of the computer. windows-commandline.com/find-domain-name-command-line
– Sriniv
Jan 18 '15 at 19:25
the smart quotes in
”Domain”
will make it fail to grep the string– phuclv
Feb 11 at 9:29
the smart quotes in
”Domain”
will make it fail to grep the string– phuclv
Feb 11 at 9:29
add a comment |
The %USERDOMAIN% and the network computer domain can be different. The systeminfo command will get the right answer but it is SLOW! Here is a solution I've used:
@REM + find the computer domain name
FOR /F "usebackq tokens=*" %%a IN (`ipconfig /all`) DO (
@((ECHO %%a | findstr /i /c:"Primary Dns Suffix") && SET _str=%%a) > NUL 2>&1
)
FOR /F "tokens=2 delims=:" %%a IN ("%_str%") do SET _computerDomain=%%a
SET _computerDomain=%_computerDomain: =%
SET _fqdn=%COMPUTERNAME%.%_computerDomain%
add a comment |
The %USERDOMAIN% and the network computer domain can be different. The systeminfo command will get the right answer but it is SLOW! Here is a solution I've used:
@REM + find the computer domain name
FOR /F "usebackq tokens=*" %%a IN (`ipconfig /all`) DO (
@((ECHO %%a | findstr /i /c:"Primary Dns Suffix") && SET _str=%%a) > NUL 2>&1
)
FOR /F "tokens=2 delims=:" %%a IN ("%_str%") do SET _computerDomain=%%a
SET _computerDomain=%_computerDomain: =%
SET _fqdn=%COMPUTERNAME%.%_computerDomain%
add a comment |
The %USERDOMAIN% and the network computer domain can be different. The systeminfo command will get the right answer but it is SLOW! Here is a solution I've used:
@REM + find the computer domain name
FOR /F "usebackq tokens=*" %%a IN (`ipconfig /all`) DO (
@((ECHO %%a | findstr /i /c:"Primary Dns Suffix") && SET _str=%%a) > NUL 2>&1
)
FOR /F "tokens=2 delims=:" %%a IN ("%_str%") do SET _computerDomain=%%a
SET _computerDomain=%_computerDomain: =%
SET _fqdn=%COMPUTERNAME%.%_computerDomain%
The %USERDOMAIN% and the network computer domain can be different. The systeminfo command will get the right answer but it is SLOW! Here is a solution I've used:
@REM + find the computer domain name
FOR /F "usebackq tokens=*" %%a IN (`ipconfig /all`) DO (
@((ECHO %%a | findstr /i /c:"Primary Dns Suffix") && SET _str=%%a) > NUL 2>&1
)
FOR /F "tokens=2 delims=:" %%a IN ("%_str%") do SET _computerDomain=%%a
SET _computerDomain=%_computerDomain: =%
SET _fqdn=%COMPUTERNAME%.%_computerDomain%
answered Sep 6 '13 at 17:43
MikeMike
111
111
add a comment |
add a comment |
@Mike: fine solution - but I had some problems with it in a multi-language enviroment.
I have German and English servers.
I changed your script to use wmic.exe:
@REM + Find the computer domain name
@echo off
FOR /F "usebackq tokens=*" %%a IN (`wmic.exe COMPUTERSYSTEM GET DOMAIN /Value`) DO (
@((ECHO %%a | findstr /i /c:"Domain=") && SET _str=%%a) > NUL 2>&1
)
FOR /F "tokens=2 delims=^=" %%a IN ("%_str%") do SET _computerDomain=%%a
SET _computerDomain=%_computerDomain: =%
SET _fqdn=%COMPUTERNAME%.%_computerDomain%
echo %_fqdn%
Thx for your idea
add a comment |
@Mike: fine solution - but I had some problems with it in a multi-language enviroment.
I have German and English servers.
I changed your script to use wmic.exe:
@REM + Find the computer domain name
@echo off
FOR /F "usebackq tokens=*" %%a IN (`wmic.exe COMPUTERSYSTEM GET DOMAIN /Value`) DO (
@((ECHO %%a | findstr /i /c:"Domain=") && SET _str=%%a) > NUL 2>&1
)
FOR /F "tokens=2 delims=^=" %%a IN ("%_str%") do SET _computerDomain=%%a
SET _computerDomain=%_computerDomain: =%
SET _fqdn=%COMPUTERNAME%.%_computerDomain%
echo %_fqdn%
Thx for your idea
add a comment |
@Mike: fine solution - but I had some problems with it in a multi-language enviroment.
I have German and English servers.
I changed your script to use wmic.exe:
@REM + Find the computer domain name
@echo off
FOR /F "usebackq tokens=*" %%a IN (`wmic.exe COMPUTERSYSTEM GET DOMAIN /Value`) DO (
@((ECHO %%a | findstr /i /c:"Domain=") && SET _str=%%a) > NUL 2>&1
)
FOR /F "tokens=2 delims=^=" %%a IN ("%_str%") do SET _computerDomain=%%a
SET _computerDomain=%_computerDomain: =%
SET _fqdn=%COMPUTERNAME%.%_computerDomain%
echo %_fqdn%
Thx for your idea
@Mike: fine solution - but I had some problems with it in a multi-language enviroment.
I have German and English servers.
I changed your script to use wmic.exe:
@REM + Find the computer domain name
@echo off
FOR /F "usebackq tokens=*" %%a IN (`wmic.exe COMPUTERSYSTEM GET DOMAIN /Value`) DO (
@((ECHO %%a | findstr /i /c:"Domain=") && SET _str=%%a) > NUL 2>&1
)
FOR /F "tokens=2 delims=^=" %%a IN ("%_str%") do SET _computerDomain=%%a
SET _computerDomain=%_computerDomain: =%
SET _fqdn=%COMPUTERNAME%.%_computerDomain%
echo %_fqdn%
Thx for your idea
edited Mar 26 '14 at 21:18
Scott
16.1k113990
16.1k113990
answered Mar 26 '14 at 20:00
BernhardBernhard
111
111
add a comment |
add a comment |
One line is enought to get the domain using a local user:
FOR /F "usebackq tokens=2 delims==" %%a IN (
wmic.exe COMPUTERSYSTEM
) DO set _computerDom=%%a
GET DOMAIN /Value ^|find /i "domain"
add a comment |
One line is enought to get the domain using a local user:
FOR /F "usebackq tokens=2 delims==" %%a IN (
wmic.exe COMPUTERSYSTEM
) DO set _computerDom=%%a
GET DOMAIN /Value ^|find /i "domain"
add a comment |
One line is enought to get the domain using a local user:
FOR /F "usebackq tokens=2 delims==" %%a IN (
wmic.exe COMPUTERSYSTEM
) DO set _computerDom=%%a
GET DOMAIN /Value ^|find /i "domain"
One line is enought to get the domain using a local user:
FOR /F "usebackq tokens=2 delims==" %%a IN (
wmic.exe COMPUTERSYSTEM
) DO set _computerDom=%%a
GET DOMAIN /Value ^|find /i "domain"
edited Jul 14 '15 at 10:34
suspectus
3,70162031
3,70162031
answered Jul 14 '15 at 10:18
BrockyBrocky
1
1
add a comment |
add a comment |
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.
add a comment |
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.
add a comment |
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.
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.
edited Feb 11 at 9:08
answered Feb 11 at 7:06
RBTRBT
164216
164216
add a comment |
add a comment |
Thanks for contributing an answer to Super User!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f468217%2fhow-to-get-domain-name-in-windows-using-command%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
For information - domain name of computer and domain name of the logged-in user might not be same.
– RBT
Feb 11 at 9:17