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 myITforum.com 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 first published in August 2005
This Content Component encountered an error

Pro+

Features

Enjoy the benefits of Pro+ membership, learn more and join.

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchServerVirtualization

SearchCloudComputing

SearchExchange

SearchSQLServer

SearchWinIT

SearchEnterpriseDesktop

SearchVirtualDesktop

Close