We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now


Help on a Windows batch file domain pc query?

Medium Priority
Last Modified: 2013-11-13
I need to be able to query the domain and take all the computer names in the domain name put them into a text file. Then I need to take those results and use them to query all the computer for their system info (name, ip ,mac) Like the DOS systeminfo command with the mac address. And save the ouput as a .csv file that contains all the information for all computers in the domain. I have alot of seperate parts ,but can't tie it al together that good. Any help is appreciated.
Watch Question

It's tough to query all the remote machines in real time but pretty easy to set up a login script that queries the PC and writes a CSV out on a network share. Is that a possibility? The simplest script would just be one line:

set > \\server\share\%computername%.txt

you can also add another line (if you are going with uter solution) for ip addresses, mac address and computer name ..etc like this:

ipconfig /all >> \\server\share\%computername%.txt

nothe that the >> will append to the file, not delte it.

hope this help

If you really want to get fancy, you can do a

fsutil fsinfo drives

which will list all the drives, then parse those with a for loop and do a

fsutil volume diskfree [drive letter]

to get the free space.

(Beat THAT for obscure DOS commands!) :-)


It is a weird scenario. I have no control over the servers, but total control over about 100 pc's running windows xp. So I won't be able to do the server thing. Thanks though.
You can use the following program to get the information that you require with out the need to have access to the server. It will also automatically export to CSV and scans the network quite quickly.


NBTscan is a program for scanning IP networks for NetBIOS name information. It sends NetBIOS status query to each address in supplied range and lists received information in human readable form. For each responded host it lists IP address, NetBIOS computer name, logged-in user name and MAC address.

Example Usage-

nbtscan.exe -q -s , > list.csv
nbtscan.exe -q -s , > list.csv

just use the above commands in a batch file and replace the IP ranges with your own.

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Also have a look at PSTools especially PsExec


PsExec will allow you to run programs remotely over a whole network of computers. The only problem is that it requires you to have a list of al of the computers on the domain. Although you could probably use nbtscan for that or some other tool.

When you said 'domain', do you have Active Directory? You can start your PC name list by exporting the contents of the Users and Computers tool, Computers folder.

The reverse approach, Make an Excel spreadsheet: put the text string "ping -n 1 -a 192.168.0." in cell A1 and copy it down to A254. (change the 192 part to match your IP addresses).
In B1, type 1, then in B2 type 2, use the pattern fill to complete the series down to cell B254.
In C1 type " >c:\pinglog.txt" and copy this all the way down to C254
Save as a text file, open it in notepad
Do a Find/Replace to remove the " and , and then save, rename to ping.bat and run it.

You can do "arp -a" for a list of IP to mac addresses shortly after your scan finishes or change the batch file above to nbtstat -A

These batch file approaches let you inventory your network, but require the PCs to be turned on.
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.