Windows IT Pro is the leading independent community for IT professionals deploying Microsoft Windows server and client applications and technologies.
  
  
  Advanced Search 


Return to article

The Magic of Drive Mapping
 

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

net use

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.







Reader Comments

This article has been very useful. Thanks.

Eloy -March 08, 2004

I like the article. I have used up every letter in the alphabet with my drives. Do you know how I can map more drives? Is there a command in Windows that will maybe let me use letters such as 'AA', 'BB', CC' and so on? If not, is there software I can purchase that will help me accomplish this objective?

David Meyer -March 17, 2004

For the last few days, we've had a PC start up with mapped drives disconnected. Your article reminded me about the need for clock synchronization. Ours had gotten a little off. Thanks.

Gary Vetter -March 24, 2004

to david meyer Don't undestand the problem of mapping drive number. I mount my vols under directory as permitted since w2k

cezanna -March 30, 2004

I am told that in the world of MS, where a server is sharing its drive for applications, when a client runs the application, the application actually runs on the server and therefore uses the server's CPU, Memory resources. This is certainly not true in the Unix world, though it may use a little CPU, and memory as well as I/O bandwidth for the over head of sharing out its drive. In regards to Windows, can you confirm where the application actually runs or point me to some documentation that explains this?

Ron Bogard -April 15, 2004

Any one knows how to rename (label) a network drive, using command line ? Usually the drive is called: folder on server (letter driver), I wolud like to rename it in FOLDER1 as you can do in driver properties with LABEL box. Thanks in advance P.

Paolo -April 20, 2004

Very informative. I grew up in the DOS world. Since GUI the DOS commenads have not gotten daily use. This really helps with the "Use it or loose it" problem. Thank you very much

ASAPCS -May 12, 2004

Can you tel me how can i rename a network drive eks:h:\\servet01$ to h:\\01s$ thanks marco

Marco -May 17, 2004

mDrive = "F:\" Set oShell = CreateObject("Shell.Application") oShell.NameSpace(mDrive).Self.Name = "AnyName"

Chizl -June 01, 2004

Try this on for size, I use it to standardize drive names across my network: set renameShell = createObject("shell.application") mappedDrive = "P:\" 'Your drive letter renameShell.nameSpace(mappedDrive).self.name = "Drive Name" Hope this helps...

Will -June 01, 2004

Does anyone know how to reverse the net config server /autodisconnect:-1 command? Or further, what the other two values are that are changed? How to get them back to their orginal state? Best regards - the guy with the ridiculous username

Tom,Tom,TomClift -October 14, 2004

Can an ID password be passed with this command?

Anonymous User -November 02, 2004

does anyone know to have a service map a drive when it starts

ministak -November 10, 2004

test

Anonymous User -November 19, 2004

I set up drive mapping on this particular computer running W2k awhile ago. Now it won't retain the mapped drive in "My Computer" for restricted user account. The shortcut for the mapped drive disappears after restarting. Now if I tried to set up a new restricted account and the mapped drive shortcut stays, even after restarting. I suspect the profile on the account I created before is corrupted. I would like to know what to check in this situation. Thanks in advance.

Anonymous User -November 19, 2004

I have a novell client that has the netuse command in their login script, even though I'm passing the userId and password, it prompts for the password each time. The server is a windows 2003 server. here is the login script text: NET USE T: \\10.28.1.2\cqi /USER:TN1772K201\cqiuser cqiuser Thanks Kirk

Anonymous User -December 10, 2004

mDrive = "F:\" Set oShell = CreateObject("Shell.Application") oShell.NameSpace(mDrive).Self.Name = "AnyName" ====>>> VERY GOOD ^^

Anonymous User -December 10, 2004

what if the person sharing the drive created the share name with spaces?

Anonymous User -December 21, 2004

Great article! Thanks.

Anonymous User -December 26, 2004

I would also love to know how to map to a shared folder with spaces in the name from the command prompt.

Anonymous User -January 04, 2005

The command from the command prompt is net use c: "\\server\file name"

Anonymous User -January 04, 2005

Wonderful. Exactly the information I was looking for (including how to rename the mapped drives)

Anonymous User -January 31, 2005

can save to a shared directory if I go to the drive where the share is located. If I map a drive to that same share I'am unable to save a file. john.jubic@doc.state.co.us

Anonymous User -February 08, 2005

Thanks for the tips....found it very useful!

Anonymous User -February 09, 2005

john.jubic@doc.state.co.us wrote: can save to a shared directory if I go to the drive where the share is located. If I map a drive to that same share I'am unable to save a file. Sounds like a problem with your share permissions. In the sharing tab, check to make sure your account or, better yet, a global group containing your account has modify permissions.

Anonymous User -February 15, 2005

Hey can anyone help with a problem I have. Usually (but not everytime) I log off and on, my computer fails to reconnect a Mapped Network drive, and I have to open Explorer and re-map it manually. I'm running XP pro over a wireless network, and the mapped drive is to a DOS based programme on another PC running 98SE. Any ideas.... in English please I'm no techy!! :-)

Anonymous User -February 22, 2005

Does someone know how to map to a local drive under XP, let'say so that c: is accessible under m: It works fine when the PC is connected to a network, but it vanishes when the PC isn't linked anymore (laptop). SUBST command works, but brings other problems (trash can). Thanks

Anonymous User -February 23, 2005

great info provided here, in simple terms allowing the novice to get started

Anonymous User -February 25, 2005

I too have a problem with permissions. I need to map a drive from an NT4 box to a W2k(Pro) Server but I don't want the users to find out the username and password to this account. How can I map a drive with persistance and username & password parsed every logon? Anyone know? I tried "different username & password" but it won't save password. ARRGhhhh!

Anonymous User -March 15, 2005

Very handy!

Anonymous User -March 16, 2005

I am admin@talente.ro, and I am using from many years mapping techniques. Yesterday I've bought a game from Microsoft and at installation it saud you can't install on a remote drive. Is it any way to make Microsoft installation program unable to identify that my mapped dirve is a remote one ? Or there is anywhere a prgram that simulate that ? Thank you

Anonymous User -March 25, 2005

I am using the vbscript posted to change the drive labels, but it limits me to 32 characters. Anyone know a way around this? Any help would be much appreciated!

jurroppi1 -April 17, 2005

How do i lable the mapped drive in command line

Anonymous User -April 19, 2005

how do i lable the mapped drive in net use comman d line... mail me to srinu2304@gmail.com thanks in advance

Anonymous User -April 19, 2005

test

OliverDawson -July 15, 2005

GREAT JOB

Anonymous User -August 05, 2005
Windows IT Pro Home Register FAQ for Windows WinInfo News
Europe Edition About Us Contact Us/Customer Service Media Kit Affiliates / Licensing  
SQL Server Magazine Office & SharePoint Pro DevProConnections IT Job Hound
Left-Brain.com Technology Resource Directory asp.netPRO ITTV Windows SuperSite 
 
 Windows IT Pro is a Division of Penton Media Inc.
 © 2009 Penton Media, Inc. Terms of Use | Privacy Statement