Mapped drives let users easily and quickly navigate a network. Using mapped drives, you can simply point and click to access network resources, whether you're working in Windows Explorer, My Computer, or software application dialog boxes such as Open or Save.
Drive mapping is nothing more than assigning a drive letter to a remote share. Because the drive letter is local, the remote resource appears in My Computer and Windows Explorer as if it were a local resource, letting you access the remote share much more quickly than you can by typing the shared folder's Universal Naming Convention (UNC) name or browsing the network for the folder.
Administrators who teach users how to map drives or who use Windows functions to automatically map drives for users spend less time in Help desk mode. And because some applications exhibit quirky behavior or otherwise don't work well with UNC names, mapped drives are sometimes necessary. However, some administrators don't understand mapping. Others do but don't know the many tricks and shortcuts that they can use to map drives. If you're in one of these two categories, read on to become familiar with the wonderful world of mapped drives.
Using the Windows GUI
The quickest and easiest way to access a share that you want to manually map is through My Network Places. (Keep in mind that you can access My Network Places through Windows Explorer and My Computer as well as through the My Network Places icon on the desktop.) In the treeview pane, expand the view of the computer that contains the share you want to map. Right-click the share and choose Map Network Drive from the shortcut menu to open the dialog box that Figure 1 shows.
By default, Windows 2000 checks the local drive letters in use and offers the next available drive letter in the alphabet for the mapped share. In contrast, Windows Server 2003 and Windows XP start with Z when looking for available drive letters, then work backward through the alphabet. If you don't want to use the offered drive letter, simply specify any other unused letter.
The Reconnect at logon option determines whether the computer will automatically connect to the drive the next time the user logs on to the machine (mapped drives are user settings, not computer settings). The first time you map a drive, the check box is selected by default. Thereafter, Windows remembers the previous state of the option and defaults to that configuration. Unless the user doesn't plan to access the share in the future, you'll typically want to select Reconnect at logon.
Reconnecting to mapped drives during start-up adds several seconds to the startup process and longer if the mapped share isn't available during start-up. A computer's ability to find and reconnect to a drive depends on whether the remote computer has completed its boot sequence. If the remote computer is booting, Windows displays the mapped drive in My Computer (and Windows Explorer) with a red X superimposed on the icon. After the share becomes available, double-clicking the icon quickly connects you to the mapped share, and the red X disappears.
Similar to the Windows RunAs feature, the Connect using a different user name option lets users who don't have permissions to work in a particular share connect to the share through a user account that has the necessary permissions. Users must supply the password of the account. Specify a username and password if you like, then click Finish on the Map Network Drive dialog box. Windows will write the information to the local computer's registry, add the new drive letter to My Computer, and open a window to display the share's contents.
If the shared folder is a parent folder and you expand it to view its child folders, you can't right-click a child folder and map a drive to it. The Map Network Drive command doesn't appear on the shortcut menu for a folder that isn't explicitly shared. You can, however, map the drive from the command line, as I explain later. To remove a mapped drive from a computer, right-click its icon in My Computer or Windows Explorer and choose Disconnect.
Using the Command Line
To map drives from the command line, use the Net Use command. This command has many switches; I discuss only the most commonly used. (You can look up the command's full syntax in Windows Help.)
To see the currently mapped drives and determine which drive letters are available, type
at a command prompt. As Figure 2 shows, the command returns the current status of each connection in addition to the drive letter, the share's UNC name, and the network. The network is typically Microsoft Windows Network, but if you run another OS, the Network column will reflect that. For example, if you run Novell NetWare client software and map drives to a NetWare server, the network will be NetWare.
To map a shared folder to a drive letter, specify the drive letter and the share's UNC name on the Net Use command. For example,
net use d: \\BigServer\DataFiles
maps the DataFiles share on the BigServer computer to drive D. If any folder in the share's path contains a space, you must put the entire path, including the opening double backslash (\\), in quotation marks.
Whether the computer will reconnect to the share at logon depends on the last state of the Reconnect at logon option. However, you don't need to open the GUI to see what the current setting is—you can simply use the /persistent: switch on the Net Use command to set the reconnection option you prefer. For example, to reconnect to DataFiles at logon, enter
net use d: \\BigServer\DataFiles /persistent: yes
To map the drive for this session only, you'd type
net use d: \\BigServer\DataFiles /persistent: no
Unlike the GUI's mapping function, the Net Use command lets you map to shared folders' child folders. To map an unshared subfolder called Clients in the shared DataFiles folder, you'd type
net use d: \\BigServer\DataFiles\Clients
With this capability, you can share a drive, then map any or all of the folders on that drive. However, you need to be exceptionally judicious about security in such cases. I use this technique only in test lab scenarios that provide a controlled environment (i.e., a discrete LAN on a hub that's unconnected to the rest of the enterprise and on which I either run a firewall or eliminate Internet access). After I share drive C of each computer that's on the LAN, I can remotely access any folder on those drives. For example, to access the LabData folder on the C drive of the TestBox server in my lab, I can type
net use d: \\TestBox\C\LabData
I can then perform any task that involves a remote folder. For example, I use mapped drives to perform backups across the network; for details, see the sidebar "Using Mapped Files for Backups."
Administrators can use the Net Use command within logon batch files to set mapped drives for users so that they can easily access frequently used folders on remote systems. For example, for users who work with the company database, you might have a logon script that contains the following lines:
net use g: \\BigServer\OurDatabase net use h: \\BigServer\DatabaseFiles
Name the batch file whatever you want (be sure it has a .bat extension), and copy it to the logon script directory on your domain controller (DC). The default location for logon scripts on a Win2K DC is %SystemRoot%\SYSVOL\sysvol\domain name.com\scripts. Win2K automatically shares the scripts subfolder with the share name Netlogon.
Be very careful not to map the drive letter assigned to user home drives. During user logon, Windows maps the home drive before running logon scripts from the scripts subfolder. If your logon script tries to map a drive letter that's already used, the system returns the message The local device name is already in use.
Automatic Disconnection of Mapped Drives
Sometimes, when a user opens My Computer or Windows Explorer, a red X appears on the mapped drive's icon, indicating that the drive isn't available. Windows automatically disconnects mapped drives after a period of inactivity (the default interval is 15 minutes) and displays a red X on the drive's icon. When that happens, clicking the icon or entering the drive letter followed by a colon (:) at the command prompt automatically reconnects the drive. But the red X also appears if the computer that holds the mapped share isn't available for some reason, in which case these steps don't work. Because users can't tell why the red X appears, they often call the Help desk.
You could cut down on those Help desk calls if you could disable the automatic disconnection of mapped drives so that users see a red X only when a remote computer is down. The Autodisconnect registry value controls the automatic disconnect. According to Microsoft, you can disable this function by setting Autodisconnect to -1. However, the registry won't let you enter a minus sign for this value. Some Microsoft support technicians suggest entering
net config server /autodisconnect:-1
at a command prompt. Although this command appears to enter a value of -1 for the Autodisconnect registry value, it actually changes the value to the maximum supported value, which is 4,294,967,295 minutes (more than 8000 years) for Win2K Professional and 65,535 minutes (more than 45 days) for Win2K Server. Both values are large enough to effectively disable the autodisconnect function. However, the Net Config command also changes two other subkey values, and these additional changes (which affect browser announcement schedules) might cause other problems.
Some administrators try changing the Autodisconnect value to 0. However, a 0 value doesn't prevent automatic disconnection of mapped drives. Rather, this value has the effect of disconnecting drives erratically and often quite quickly.
The best approach is to explicitly set Autodisconnect to the maximum supported value. Start a registry editor (e.g., regedit.exe) on the computer that holds the share (not the remote computer that maps the share). Navigate to the HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters subkey, and double-click the Autodisconnect registry value. If the computer on which the share resides is a Win2K Pro workstation, enter a new decimal value of 4294967295 or a new hexadecimal value of ffffffff. If the computer is a Win2K server, enter a new decimal value of 65535 or a hex value of 0xffff.
Kerberos and Mapped Drives
In a Win2K domain, the Kerberos authentication functions determine whether you can access shares. Kerberos relies on the Windows Time Service during authentication, and if the local computer's clock doesn't show the same time (within a certain tolerance) as the remote computer's clock, Kerberos won't let you access shares on the remote computer.
The default behavior of a Win2K computer in a Win2K domain is to sync its time with the DC's time every 45 minutes. When the clock times match, the synchronization interval is incrementally extended until it reaches 8 hours or until the clocks don't match. (For details about how Windows Time Service works, see Windows 2000 Ready, "Windows Time Synchronization Service," http://www.winnetmag.com, InstantDoc ID 8383.) If you've changed that paradigm, if a computer's clock is losing time because of semiconductor problems, or if the DC's time is wrong, Kerberos settings cause mapped drives to be disconnected.
I learned this accidentally while writing a book about accounting software. Every transaction window in accounting software has a date, so to make sure the book's figures would match the publication date, I set the date on the computer that was running the accounting software to the next year. I saved the figure files to a mapped drive on the computer on which I do my writing. When I finished writing the paragraphs and returned to the computer that was running the accounting software, I found that it had reset its date to the current year. I remembered that the workstation was syncing its time to the DC. The solution, I decided, was to change the system time, then grab the figure before the system next checked its time against the DC's time. However, when I attempted to save the figure file to the mapped drive, I received an error message about security and learned that the mapped drive was disconnected. I couldn't reconnect the drive until I fixed the time. Finally, I logged on to the local computer instead of the domain, saved the figure files locally, logged on to the domain again, then used Windows Explorer to transfer the files to the mapped drive.
A Mapped-Drive Bug
When you map a drive from the GUI, Windows opens a window for the new mapped share as soon as you click Finish. Thereafter, whenever you map that same drive letter, even from the command line, Windows opens a window and displays the contents of the shared resource. If you subsequently use a batch file to map the drive, the appearance of the window interrupts processing (defeating the purpose of an "unattended" job).
To prevent this behavior, Microsoft issued a downloadable fix, which you can obtain by calling Microsoft support. (If you report this problem, you won't be charged for the call.) The support technician will direct you to the proper FTP download of a replacement for the shell32.dll file. The Microsoft article "Mapping a Drive from a Command Prompt May Open a New Windows Explorer Window" (http://support.microsoft.com/?kbid=290703) discusses this problem and suggests a registry fix. However, the suggested registry modification doesn't work.
One way to prevent this behavior is to use only the Net Use command, never the GUI, to map drives. Alternatively, if you use the GUI, press and hold Shift when you click Finish and continue to hold down Shift for at least 10 seconds.
A Powerful Combination
Mapped drives combine computing power with ease of use—a potent combination. Use batch files and logon scripts to share this often overlooked power tool with your users—or teach them to map their own drives—and you as well as they will reap the rewards.