Solved

Network Drive Mapping

Posted on 2011-03-08
5
364 Views
Last Modified: 2012-05-11
I'm setting up a small bit of VBA Code to map a network drive if the path isn't available and i've got that to work but the mapping is showing up as
blank on 'UNC PATH'

rather then the usual
folder on 'UNC PATH'

is there anyway to fix that here is an example of the code

    Set wshNetwork = CreateObject("WScript.Network")
    Set colNetDrives = wshNetwork.EnumNetworkDrives
   
    For X = 71 To 90 'Letters G through Z
        DrvFound = False
   
        For Y = 1 To colNetDrives.Count - 1
            If colNetDrives.Item(Y) = Chr(X) & ":" Then
                DrvFound = True
            End If
        Next Y
       
        If Not DrvFound Then
            strDriveLtr = Chr(X) & ":"
            Exit For
        End If
    Next X
   
    wshNetwork.MapNetworkDrive strDriveLtr, sDRIVEMAPPING, True

End Sub
0
Comment
Question by:Thrawn3000
  • 3
5 Comments
 
LVL 41

Expert Comment

by:Jackie Man
ID: 35077469
Run a ipconfig /all in command prompt and post back the results.
0
 
LVL 6

Expert Comment

by:Kody-Burg
ID: 35077472
Not entirely sure what you are asking, but I don't see anything in your code that actually tells the system where to map the drive to. You can do that with the following code:

Set objNetwork = CreateObject("WScript.Network")
objNetwork.MapNetworkDrive "K:", "\\SERVERNAME\FOLDER"
                                               ^                           ^
                                          Drive Letter           Folder Location
0
 

Author Comment

by:Thrawn3000
ID: 35077649
Ok could better explain what i'm asking,

say i have the following UNC pathname

\\SERVER\FOLDER1\FOLDER2\FOLDER3\

When mapped manually through the 'Map Network Drive..' feature in windows XP it becomes

FOLDER3 on '\\SERVER\FOLDER1\FOLDER2'

when i use the code

wshNetwork.MapNetworkDrive strDriveLtr, sDRIVEMAPPING, True

strDriveLtr = the drive letter i'm assigning the map to
sDRIVEMAPPING = the UNC pathname

it comes up

 on \\SERVER\FOLDER1\FOLDER2\FOLDER3\

instead
0
 
LVL 41

Expert Comment

by:Jackie Man
ID: 35077847
The UNC path should be \\SERVER\FOLDER1\FOLDER2\FOLDER3 instead of \\SERVER\FOLDER1\FOLDER2\FOLDER3\
0
 
LVL 41

Accepted Solution

by:
Jackie Man earned 500 total points
ID: 35077856
You add an additional "\" after the UNC path.
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Most of the time we are in fix when all of sudden our systems behave weirdly.  Such problems cost time and effort... so it's best to take some preventive actions so that we can avoid such issues or overcome such problems more easily. Preventive M…
Can you find a fax from a vendor you saved a decade ago in seconds? Have you ever cursed your PC under your breath during an audit because you couldn’t find the requested statement or driver history?  If you answered no to the first question or yes …
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now