Problem solve Get help with specific problems with your technologies, process and projects.

Script retrieves remote drive mappings and printers

This handy VBScript allows a remote computer to retrieve a list of mapped network drives and printers.

Please let us know how useful you find this tip by rating it below. Do you have a useful Windows tip, timesaver...

or workaround to share? Submit it to our tip contest and you could win a prize!

Use this VBScript to connect to a remote computer and retrieve the list of mapped network drives and printers.

For this script to work remotely, you will need to run through the steps for creating a Remote WSH instance. This is possible using WSH 5.6 or higher. To review how to set up a Remote WSH instance, read this article: Setting Up Remote WSH.

Note: Make sure you have the latest scripting engines on the workstation from where you run the script below. Download the latest scripting engines here: Microsoft Scripting Home Page.

================================== CompName = inputbox("enter computer name") Set Connect = GetObject("WinNT://"&CompName) Set WshNetwork = WScript.CreateObject("WScript.Network") Set oDrives = WshNetwork.EnumNetworkDrives Set oPrinters = WshNetwork.EnumPrinterConnections WScript.Echo "Network drive mappings:" For i = 0 to oDrives.Count - 1 Step 2 WScript.Echo "Drive " & oDrives.Item(i) & " = " & oDrives.Item(i+1) Next WScript.Echo WScript.Echo "Network printer mappings:" For i = 0 to oPrinters.Count - 1 Step 2 WScript.Echo "Port " & oPrinters.Item(i) & " = " & oPrinters.Item(i+1) Next ==================================

Note: When working with the Active Directory Services Interface (ADSI), you must have the same applicable rights as you would using the built-in administrative tools.

Rod Trent, manager of and a Microsoft MVP, is an expert on Microsoft Systems Management Server. He has more than 18 years of IT experience -- eight of which have been dedicated to SMS. He is the author of Microsoft SMS Installer, Admin911: SMS, and IIS 5.0: A Beginner's Guide and has written thousands of articles on technology topics.
This was last published in August 2005

Dig Deeper on Windows Server storage management

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.