• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1264
  • Last Modified:

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.
1 Solution
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
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

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now