Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have the following batch script which is successfully mapping a few of our drives for our users:

@echo off
net use * /delete /yes
net use x: \\\xrays
net use s: \\\common
net use p: \\\public
net use o: \\\office
net use y: \\\drives

The mapped drives are taking their names from the share name themselves. However, it would be really handy if I could override the name to something more useful to the users.

I have looked at quite a few documents online with examples of the net use commands, but I can only see options such as credentials but nothing to do with the naming.

The script is being run on Windows XP and Windows 7 workstations.

Any help would be appreciated.

share|improve this question

There is no way to do this using only the net use command (see documentation), but there is a way to do this using a vb script, as described by Guy Thomas at here

In case his Guy's site disappears later, here is his a copy of his script:

' NameDrive.vbs
' VBScript to map a network drive.
' Authors Guy Thomas and Barry Maybury
' Version 1.4 - April 2010
' ----------------------------------------'
Option Explicit
Dim objNetwork, strDrive, objShell, objUNC
Dim strRemotePath, strDriveLetter, strNewName
strDriveLetter = "W:"
strRemotePath = "\\\example\sharename"
strNewName = "Example Readable Label"

' Section to map the network drive
Set objNetwork = CreateObject("WScript.Network")
objNetwork.MapNetworkDrive strDriveLetter, strRemotePath

' Section which actually (re)names the Mapped Drive
Set objShell = CreateObject("Shell.Application")
objShell.NameSpace(strDriveLetter).Self.Name = strNewName

Wscript.Echo "Check : "& strDriveLetter & " for " & strNewName

' End of Example VBScript.


  • If W: doesn't work for you, try W:\ (with the slash)
  • This method will set the drive letter label permanently, i.e. if you later connect another share to the same drive letter, that new share will also get the old label. This can be fixed by either always using this script when connecting shares, or by deleting a key in the registry to revert to normal behaviour.

Reverting to normal behaviour:

  • Launch regedit and then click on Edit (menu) -> Find -> Example Readable Label
  • Or navigate in regedit to HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\MountPoints2 -> _LabelFromReg
  • Just delete the value - leave it blank. The result will be that future drive mapping will revert to the traditional style of mapping.

All of this is more thouroguhly described at Guy's website.

share|improve this answer

There is way to do it from the command line without using VBScript. You can edit the registry using the reg add command. IMHO, doing it this way will be better than using VBScript to change the label because it will not associate the label with the drive letter, but rather it will associate the label with the share. So, if the end user later disconnects X: and manually mounts the xrays share to say the R: drive, then the label will still show up correctly (to whatever you assigned it in the script).

The key you will be writing to is HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\MountPoints2\ with the sub-key being the share path with all of the backslashes replaced with pound symbols (#).

Note: I have not yet tested how you should handle share names with spaces (or even pound symbols) in them.

@echo off

net use * /delete /yes

:: Set the label in the registry
reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\MountPoints2\## /v _LabelFromReg /t REG_SZ /f /d "X-Rays"
:: Map the drive
net use x: \\\xrays

reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\MountPoints2\## /v _LabelFromReg /t REG_SZ /f /d "Common"
net use s: \\\common

reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\MountPoints2\## /v _LabelFromReg /t REG_SZ /f /d "Public"
net use p: \\\public

reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\MountPoints2\## /v _LabelFromReg /t REG_SZ /f /d "Office"
net use o: \\\office

reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\MountPoints2\## /v _LabelFromReg /t REG_SZ /f /d "Drives"
net use y: \\\drives

share|improve this answer
This is great, as it doesn't need VBScript to be done. Thank you. – Zulakis Sep 10 '14 at 10:37
@echo off
echo --------------------------delete map drive all------------------------
net use * /delete /yes
echo ------------------create drive --------------------------------
net use m: \\\Source /user:aleg\masr masr2006*
net use n: \\\scanner_bat_test /user:alwq\4288044 masr2006*
echo ---------------------------------------------------

share|improve this answer
Welcome to Super User! Please edit your post and explain what the code does exactly. Also check our formatting help and use the preview to take a look at your posts before submitting. You have to indent code by 4 spaces. – slhck Dec 16 '12 at 11:20
Thanks, could you explain what each line does. It's hard to distinguish which parts are the passwords and drive names etc. – dannymcc Dec 17 '12 at 0:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .