Batch file wanted to list all shares on network by servername/share

I have a network with several hundred Windows 2003 servers.  I need to get a list of all of the network shares by servername.  I am hoping this can be done by using a batch file.

Preferrably, I would like to have a text file that lists each server name.  The batch file would take each server name, check the server, and then append an output text file with the shares for that server.  It would then continue down the server list until it reached the end.  The text file would look something like this:


The exact format doesn't matter as much as just being able to collect the information in a text file.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

From WinDrivers forum...
I will be making use of this myself.

net view /domain:Your_Domain>>machinelist.txt
for /f %%i in (machinelist.txt) do net view %%i>>shares.txt
del machinelist.txt

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
SteveAuthor Commented:
Exactly what I needed, Dabecs.  Thanks!
Here is a script I recently created myself which would do what you need:
All you need is a file(input file) list all ther servers which can be easily obtained from many different sources, even with ADCU's export list feature. The other file is the output file which will automatically be created with info as you needed: ServerName, ShareName & Path. Each servername will be separated by a line. I inlcuded the path thinking that it may be useful for you but you can take it out as you wish.
Hope this help.
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.CreateTextFile("C:\temp\ServerList-Out.txt")
Set objFileIn = objFSO.OpenTextFile("C:\temp\ServerList-In.txt", 1)
Const ForAppending = 8
Set objFileOut = objFSO.OpenTextFile("C:\temp\ServerList-Out.txt", ForAppending)
Do Until objFileIn.AtEndOfStream
 	strLine = objFileIn.ReadLine
	On Error Resume Next
	strComputer = strLine
	Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
	Set colItems = objWMIService.ExecQuery("Select * from Win32_Share",,48)
	objFileOut.WriteLine "ServerName: " & strComputer
	For Each objItem in colItems
    		objFileOut.WriteLine "ShareName: " & objItem.Name
    		objFileOut.WriteLine "Path: " & objItem.Path

Open in new window

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Legacy OS

From novice to tech pro — start learning today.