Windows 7 disconnected network drives

Mapped network drives have always been a buggy area in Windows, probably at least in part because they are still linked to a DOS namespace. From MSDN:

On Windows Server 2003 and Windows XP, the WNet functions create and delete network drive letters in the MS-DOS device namespace associated with a logon session…

Whatever the reason, it is commonly reported that mapped network drives appear as ‘disconnected’ in Windows Explorer (or ‘unavailable’ via net use), and that programs that attempt to use these drive mappings will fail until the user physically clicks on the drive letter in Windows Explorer. Only this user-initiated action will restore the connection and allow other programs to successfully read from the drive letter.

The dreaded disconnected network drive balloon.

This is a BIG problem!

I initially thought that the mapping of the network drives was being done before some required services had started (such as the Workstation and Server services), so I wrote a program to run on startup that attempted to map a drive and logged all the currently running services if it failed. It would keep trying to map a drive until it succeeded. I hoped it would show me which services needed to be running in order to map a drive, after which I would write a program to wait for those services before attempting to map anything. But, much to my amazement, I found that when the initial drive mapping failed and a subsequent attempt succeeded, the set of running services had not changed! So I could only conclude that there was another element in the equation. After thinking about this for a while, and reading this post, which indicates that Microsoft is apparently trying to address this, I decided ‘stuff it’, I’ll just write something that I know will work and is simple.

So I’ve written a small executable called MapDrive.exe to ‘work around’ this problem, described on the following dialog:

About MapDrive

Now as you may know since Vista, there is the concept of a split user token, and mapped network drives apply to only one token, so if you map drives as a standard user and then run an elevated process, those network drives are not available to the elevated process. This behaviour is documented by Microsoft, however the solution they offer is both unsupported and unsafe. Other solutions have been proposed here. If you don’t wish to use any of these solutions, you can do this:

1. Run MapDrive.exe as a shortcut from your Startup folder. This will map drives for the standard user token.
2. Run MapDrive.exe as a local group policy logon script using gpedit.msc. This will map drives for the administrator token.

Note: After using this program, you may still see the above balloon popup, simply click the spanner icon, and select ‘Hide icon and notifications’ for ‘Windows Explorer’.

Download the utility for free here.

UPDATE: A few people have asked how to use this program. As stated above, there are two ways, depending on whether you need drives mapped for standard users or admins. If you don’t know what you need, you probably just need to do this for standard users. Here are the steps for both:

1. Copy MapDrive.exe to somewhere on your local hard drive.

Standard Users:
2. Right-click MapDrive.exe and choose ‘Create Shortcut’. This will create a file called ‘MapDrive.exe – Shortcut’ next to MapDrive.exe. Now go Start->All Programs, right-click the ‘Startup’ folder and choose ‘Open’. Now copy the shortcut file you made before to this folder. Now right-click the shortcut file and choose ‘Properties’. Add the drive letter and network share as argument to the end of the ‘Target’ field e.g. “C:\Users\joeblogs\Documents\MapDrive.exe s: \\server\share 20″. You are done, next time you reboot, your s: should be mapped successfully for standard users.

Admin Users:
3. Press Win+R, type gpedit.msc, go User Configuration->Windows Settings->Scripts. Double-click Logon, click ‘Add’ and enter script name (no quotes): “C:\Users\joeblogs\Documents\MapDrive.exe” and script parameters (no quotes): “s: \\server\share 20″, ok, ok, done. You are done, next time you reboot, your s: should be mapped successfully for admin users (i.e. elevated programs).

  1. Rhys says:

    Hi I am having the same problem.
    Trying to access mapped drives on an OpenSolaris server that I connect to via CIFS Workgroup mode and network via my router.
    I tried using this program as an Admin and Standard user but couldn’t get it to work.
    As Standard the Target looked like:
    “C:\MapDrive.exe r: \\SERVER NAME\SHARE”
    The shares were named according to how they appeared on the actual server and UNC naming etc e.g. \\SERVER\tank_share.
    This is such an annoying problem as I can only make full use of the server if I “Sleep” the Windows 7 client, otherwise… restart and the drives are gone.
    The only solution I have found to this problem is to reboot the OpenSolaris server completely (while the Windows 7 PC is running) which is far from ideal.
    Thankyou,
    Rhys

  2. Mike says:

    Thanks for this!

    Just a tip since it took me a while to figure this out. If you have a space in your share, the syntax in the target field looks like this:

    network sever name and share: \\MIKEDESKTOP\(D) Media

    This works:
    “C:\Program Files\mapdrive\MapDrive.exe” p: “\\MIKEDESKTOP\(D) Media” 20

    This does not work:
    “C:\Program Files\mapdrive\MapDrive.exe” p: \\MIKEDESKTOP\(D) Media 20

  3. Roy Martin says:

    This resolved the issue I was having where connecting to persistent mapped drives off of the domain would cause windows boot to hang 30-60 seconds. I adjusted my setting to be 5 seconds, and it appears to work very well.

    Thank you,
    Roy

  4. David says:

    I had no luck with this using Window 7 Home. Method 1 seems to do nothing, and gpedit.msc doesn’t exist in Home apparently. This whole Win 7 local network sharing/mapping is very annoying and a big time waster. Thanks for trying to help though.

  5. David D says:

    I noticed this issue right away with Windows 7, and this utility works flawlessly! Great job and thanks!

  6. Edward says:

    Hi,
    I have a problem in configuring MapDrive and I hopefully you can help me. I presently have 3 network drives (d:,e: and f:) mapped under Win7. They appear as follows:
    wd_10 (d) (\\Server) (Q:), wd_11 (e) (\\Server) (R:) and wd_12 (f) (\\Server) (S:).

    I do not understand how to configure the targetfield of my MapDrive.exe shortcut. I always get: “The name specified in etc…..is not valid.” as a result.

    Kind Regards,
    Edward Sluijter
    The Netherlands

    • Mr. Bungle says:

      You have to run MapDrive.exe once for each drive you want to map. E.g. create three shortcuts as follows:

      [path to MapDrive.exe] Q: “\\server\wd_10 (d)” 20
      [path to MapDrive.exe] R: “\\server\wd_11 (e)” 20
      [path to MapDrive.exe] S: “\\server\wd_12 (f)” 20

      Hope that helps.

  7. Mike VM says:

    One question:

    Upon startup, I get a Map Drive window that says:

    Makes mapping drives on Windows7 startup reliable. Etc., etc. (for a whole paragraph).

    The window has an OK button at the bottom.

    How do I set things up so this doesn’t come up at startup, yet keeping the functionality of the utility?

    My setup has the MapDrive shortcut in the startup folder.

    Thanks,

    Mike

    • Mr. Bungle says:

      Mike, you need to follow the instructions in the post above, after you add the shortcut, you need to modify it to have some command line arguments specifying which drive letter should be mapped to which UNC path.

  8. Mike VM says:

    Mr. Bungle,

    I did do that, although I might not have done it correctly.

    Here’s my instruction:

    “C:\Program Files\Zorn Mapped Folder Fix Software\MapDrive.exe” q:”\\10.0.0.251\Cmpltd_Projects” 20

    See anything wrong there?

    Thanks,

    Mike

  9. Mike VM says:

    Dohhh!

    That worked. Thanks for your help.

  10. Dave says:

    I have an XP Pro machine that maps a couple volumes hosted on a Mac using SMB. Once I got this working it was great. I keep all my work on these volumes, so my XP work files get backed up hourly by Time Machine.

    I have the same issue where mapping the drives does not happen reliably, I have a .bat file that gets called at XP startup, and I’ve had to resort to adding a 20 second delay before attempting to map the drives with net use. That seems to work pretty reliably, but the delay is kind of irritating.

    I tried out MapDrive.exe, but unfortunately I am not able to use it – I need to specify a username and password to mount these volumes, which apparently MapDrive.exe does not support…? Just curious whether you might add that in the future.

    Regards,

    Dave

  11. Doug says:

    Hi,

    The program works great, although is it possible to map drives using a different credentials?

    I’ve tried using the normal syntax of h: \\server\share /user:username password but no joy.

    Cheers

    Doug

  1. There are no trackbacks for this post yet.

Leave a Reply