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: \\192.168.1.52\xrays
net use s: \\192.168.1.52\common
net use p: \\192.168.1.52\public
net use o: \\192.168.1.52\office
net use y: \\192.168.1.52\drives
EXIT
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.
Best 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 disconnectsX:
and manually mounts thexrays
share to say theR:
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.