Link to home
Start Free TrialLog in
Avatar of annexit
annexitFlag for United States of America

asked on

Add 'Map network drive' to Explorer right-click for all folders

Greetings experts!  I'm wondering if there's a way to add the right-click context menu option "Map network drive" to any folder in Explorer.  By default it only appears if you right-click the share itself.  This is for XP, 7, and 2008R2.

I'm asking because we often find ourselves very deep into a UNC path and it would be super convenient to just right-click on the folder we're in at that moment and map a network drive to it (and have the path pre-populated).

Example:  I'm on a UNC share with this very long path \\server\share\path1\test\temp\bob\stuff\dig5\code\buston\commands\depot
...and I want to right-click on the "depot" folder and map a drive directly to it.

I've spent some time researching this but so far no luck.  Thoughts?
ASKER CERTIFIED SOLUTION
Avatar of netcmh
netcmh
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi,

Why persueing the right click way when you can copy the UNC and open My Computer, click on 'make a networkshare' paste in your UNC and point to a drive letter?
I haven't tried this, because I modify the registry only when necessary, but this should work. Of course, you should take heed of the normal caveats/cautions when modifying the registry!

First, add a MapDrive selection to the context menu. Put the following in a .REG file and run it (I used shell32 icon #19...a "network" of three screens...pick whatever one suits your fancy):

[HKEY_CLASSES_ROOT\Folder\shell\MapDrive]
@="&MapDrive"
"Icon"="shell32.dll,19"
"MultiSelectModel"="Single"

[HKEY_CLASSES_ROOT\Folder\shell\MapDrive\command]
@="C:\\MapDrive.bat \"%1\""

Second, create the [MapDrive.bat] file in the C root (or wherever you want it...modify the location in the registry accordingly):

@echo off
set /p dl=Enter drive letter:
net use %dl%: %1

The context menu pick will send the fully qualified folder name to the batch file as arg 1 and the batch file will prompt for a drive letter. Both arguments are then sent to the [net use] command. It does no checking for drive letter availability, so if the drive letter is already in use, [net use] will simply come back with error 85..."The local device name is already in use." Regards, Joe
Avatar of annexit

ASKER

Thanks netcmh!  For reference I'm posting the registry file text here in case the link is ever taken down.  Basically copy everything below this paragraph into Notepad and save it as a .reg file, then double-click to import it.

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\shell\Map Drive Here]
@="Network Drive Here"
[HKEY_CLASSES_ROOT\Directory\shell\Map Drive Here\command]
@="net use I: %1"

[HKEY_CLASSES_ROOT\Directory\shell\Map Drive DELETE]
@="Network Drive DELETE"
[HKEY_CLASSES_ROOT\Directory\shell\Map Drive DELETE\command]
@="net use I: /delete /y"
Thank you for the grade. Good luck.