We help IT Professionals succeed at work.
Get Started

Map Multiple Network Drives with Friendly Names

Undisputed asked
Last Modified: 2015-01-05
Hello -

I used a script from https://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_24155507.html and wanted to know how I can modify it so that it shows friendly names for the network drives if I have multiple mapped drives.

Thanks in advance...

Option Explicit
Dim objSyncTime
Dim objShell : Set objShell = CreateObject("WScript.Shell")
Dim strDomain
Dim objNetwork
Dim strUNCPrinter
strDomain = "some.domain.com"
'Sync time
objSyncTime = objShell.Run("net time /domain:" & strDomain & " /set /y",0 , False)
'Map printer
'Usage: MapPrinter "\\<print-server>\<printer-name>", "True" or "False"
'To map the printer as the default, use "True"
MapPrinter "\\evserver\xerox c525", "True"
'MapPrinter "\\evserver\someotherprinter", "False"
'Map network drive
'Usage: MapDrive "<drive-letter>:", "\\<server>\<share>"
MapDrive "R:", "\\evserver\resources"
MapDrive "S:", "\\evserver\anothershare"
MapDrive "T:", "\\evserver\yetanothershare-etc"
Sub MapPrinter(strPrinterPath, strPrinterDefault)
    On Error Resume Next
    Dim objNet
    Set objNet = CreateObject("Wscript.Network")
    objNet.AddWindowsPrinterConnection strPrinterPath
    WScript.Sleep 1000
    If UCase(strPrinterDefault) = UCase("TRUE") Then
        objNet.SetDefaultPrinter strPrinterPath
    End If
End Sub
Sub MapDrive(strDrive,strShare)
    On Error Resume Next
    Dim objNet
    Set objNet = CreateObject("Wscript.Network")
    objNet.MapNetworkDrive strDrive, strShare
    If Err.Number Then
        objNet.RemoveNetworkDrive strDrive
        objNet.MapNetworkDrive strDrive, strShare
    End If
End Sub

Open in new window

Watch Question
This problem has been solved!
Unlock 1 Answer and 4 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE