How to retrieve a list of shared folders shared using a script

Author:

Nirmal Sharma MVP

COMMUNITY SOLUTIONS CONTENT DISCLAIMER

MICROSOFT CORPORATION AND/OR ITS RESPECTIVE SUPPLIERS MAKE NO REPRESENTATIONS ABOUT THE SUITABILITY, RELIABILITY, OR ACCURACY OF THE INFORMATION AND RELATED GRAPHICS CONTAINED HEREIN. ALL SUCH INFORMATION AND RELATED GRAPHICS ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT AND/OR ITS RESPECTIVE SUPPLIERS HEREBY DISCLAIM ALL WARRANTIES AND CONDITIONS WITH REGARD TO THIS INFORMATION AND RELATED GRAPHICS, INCLUDING ALL IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, WORKMANLIKE EFFORT, TITLE AND NON-INFRINGEMENT. YOU SPECIFICALLY AGREE THAT IN NO EVENT SHALL MICROSOFT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY DIRECT, INDIRECT, PUNITIVE, INCIDENTAL, SPECIAL, CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF USE, DATA OR PROFITS, ARISING OUT OF OR IN ANY WAY CONNECTED WITH THE USE OF OR INABILITY TO USE THE INFORMATION AND RELATED GRAPHICS CONTAINED HEREIN, WHETHER BASED ON CONTRACT, TORT, NEGLIGENCE, STRICT LIABILITY OR OTHERWISE, EVEN IF MICROSOFT OR ANY OF ITS SUPPLIERS HAS BEEN ADVISED OF THE POSSIBILITY OF DAMAGES.

SUMMARY

The following knowledgebase will explain the methods you can use to check the shared folders shared on local and remote computer.

MORE INFORMATION

To check on local computer:
 
You can use the following methods:
 
  1. Connecting to Remote Registry Service
  2. Using a script
 
The first method is easy but includes a lot of efforts. You can navigate to the following location in registry after connecting to remote registry:
 
HKLM\System\CurrentcontrolSet\Services\Lanmanserver\Shares
 
The above registry key includes the list of shared folders in right pane.
 
To check on a Remote Computer:
 
You can use the below script to check the list of shared folders on a remote computer:
 
@echo off
 
Srvlist=C:\Temp\Srvlist.txt
 
Echo Computer Name, Shared Folders Lists >> Result.csv
 
SET Share_name=
 
For /F “Tokens=*” %%a In (%srvlist%) Do (
 
Set Comp_name=%%a
 
Set RegQry=”\\%%a\HKLM\System\CurrentcontrolSet\Services\Lanmanserver\Shares”
 
REG.exe Query %RegQry% > CheckCC.txt
 
FOR /f “Skip=4 Tokens=1” %%b in (CheckCC.txt) DO (
 
            SET Share_name=%%b
 
Echo %Share_name% >> Result.csv
 
)
 
)
 
The above script will check remote computer for each registry entry in the right pane fto check the share name and the results will be saved in a CSV format file.
Properties

Article ID: 556023 - Last Review: 14 Feb 2017 - Revision: 1

Microsoft Windows Server 2003, Datacenter Edition (32-bit x86), Microsoft Windows Server 2003, Enterprise Edition (32-bit x86), Microsoft Windows Server 2003, Standard Edition (32-bit x86), Microsoft Windows Server 2003, Web Edition, Microsoft Windows 2000 Enterprise Edition, Microsoft Windows 2000 Professional Edition, Microsoft Windows 2000 Service Pack 4, Microsoft Windows 2000 Standard Edition

Feedback