Introduction to Map Network Drive - Multiple Drives
If a job is worth doing, then it's worth doing well. Once you have mastered the basic MapNetworkDrive method, you may wish
to add more drive letter mapping to your Windows logon script. Here is how you map multiple drives to network shares.
Perhaps in addition to a home folder, your users need to access a second shared folder on the server. The answer is one logon script which maps both shares. An alternative scenario is that you are building a
script which maps drives depending on which group a user is a 'member of'. In this instance. you create a selection of mapped drives, but only one is actually implemented.
Our objective is to map two drives, M: and P: with a logon script. The corresponding shares are held on a Windows 2003 server. However, you could use any Microsoft machine later than Windows
95 to host the shared folders.
Pre-requisites for MapNetworkDrive
On Line 15 change the server name from '\\alan' to your server name.
Make sure that your server has a share called '\drivers', and another called 'download reports'. Alternatively, edit the sharename in the script, and type in the name of your UNC path.
Instructions for multiple Mapped Network Drives
Copy and paste the script below into notepad.
Change the server name from "\\alan to the name of your server.
Make sure that you have not one, but two network shares on your server.
Save the file with .vbs extension e.g. MNDMultiple Drives.vbs.
Double click the logon script and check in your Windows Explorer for two new drives called : drivers on 'alan' (M:) and
download reports on 'alan' (P:).
' TwoMap.vbs - Map Network Drive to M: and P: ' Example of VBScript Mapping two drives in one script. ' Author Guy Thomas http://computerperformance.co.uk/ ' Version 1.6 - April 24th 2010 '
----------------------------------------------------' Option Explicit Dim objNetwork, strRemotePath1, strRemotePath2 Dim strDriveLetter1, strDriveLetter2
' Section which maps two drives, M: and
P: objNetwork.MapNetworkDrive strDriveLetter1, strRemotePath1 objNetwork.MapNetworkDrive strDriveLetter2, strRemotePath2
' Extra code just to add a message box WScript.Echo "Map drives " &
strDriveLetter1 & " & " & strDriveLetter2
Wscript.Quit
' End of Windows Logon Script Example
Guy
Recommends: A Free tool from SolarWinds: Config Generator
Config Generator (CG) is a free tool, which puts you in charge of
controlling changes to network routers and other SNMP devices.
Boost your network performance by activating network device features
that you've already paid for.
Guy says that for newbies the biggest benefit of this free tool is that
it will provide the impetus for you to learn more about configuring the SNMP
service with its 'Traps' and 'Communities'.
Note 1: There are a surprising number of traps when mapping multiple drives. The central point is that each new drive letter has its own line. objNetwork.MapNetworkDrive strDriveLetter2,
strRemotePath2
Note 2: You could repeat the above line for each share you want to map, provided you change the strDriveLetter2 and strRemotePath2. Mistakes arise where people get too clever and try to map 6 drives all on one
line.
Note 3: From a scripting point of view, just create one object. It is not necessary to Set objNetwork1, objNetwork2 for each drive, just recycle the one variable -
objNetwork.
Note 4: Although I disapprove, it is possible to use share names with spaces, for example, "download reports".
The modern group policy method of drive mapping does not require any
scripting. In Windows Server 2008 you can launch the Group Policy
Management Console and configure Drive Maps by clicking with a mouse.
See more on Windows 8 Group
Policy Drive Maps.
There may be situations where you need not one, but many mapped network drives. As with many scripting jobs, there is a knack of getting the correct logic and syntax. My advice is build
your Windows VBScript gradually, master the basic logon script before attempting this more difficult example of multiple map network drives.
The extra features you get in your eBook
include, more pages full of detailed examples. Also, ten 'how to...'
sections, with screen shots showing which menus to use. Go for Guy's
eBook - and get a printable version with copy enabled and no expiry date.
Windows Management Instrumentation (WMI) is one of the hidden
treasures of Microsoft operating systems.
Fortunately, Solarwinds
have created the
Free WMI Monitor so that you can actually see and understand these gems of
performance information. Take the guess work out of which
WMI counters to use for applications like Microsoft Active Directory,
SQL or Exchange Server.