Use VBScript to rename mapped drives

Through a bit of simple registry editing or a VBScript, you can easily rename mapped drives to hide share paths or make the drive name user-friendly.

On occasion, an administrator may need to change drive-mapping names to hide share paths or to make the drive name

user-friendly. If done manually through a console, this is a simple-enough operation.

But try to automate the task and it gets more difficult. Because mapped drives are not partitions on the local hard disk, common DOS commands can't be used. Most drive-mapping commands, such as net use, don't have a way to customize the name of the mapped drive either.

One way to perform this task is to hack the following Registry key and add the _LabelFromReg string value:

HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\MountPoints2\%key%

Here, the %key% variable is the drive letter to be changed.

There are several ways to make this method work. You can edit the Registry directly, via script, or by importing a .reg file using regedit/c. But all these methods require many steps and some require external files, and so they might not fit into every administrative scheme. Here's an easier approach.

Using a VBScript can make this task more seamless. This simple script can be used on mapped drives as well as local partitions:

mDrive = "drive letter" Set oShell = CreateObject("Shell.Application") oShell.NameSpace(mDrive).Self.Name = "AnyName"

To use this trick, simply edit the script to change the drive letter and drive name as desired. For example, if Z: is a mapped drive that has the label "Backup of all servers" and you want to change the label on the mapped drive to simply Backup , change this line:

mDrive = "drive letter"

to this:

mDrive = "z:\" Then, change this line:

oShell.NameSpace(mDrive).Self.Name = "AnyName"

to this:

oShell.NameSpace(mDrive).Self.Name = "Backup"

Finally, run the script by creating a shortcut to it and double-clicking on the shortcut, either by calling it from a logon script or by any other method suitable for your environment.

About the author: Rahul Shah currently works at a software firm in India, where he is a systems administrator maintaining Windows servers. He has also worked for various software firms in testing and analytics, and also has experiences deploying client/server applications in different Windows configurations.

More information on this topic:


 

This was first published in August 2006

Dig deeper on Microsoft Windows Data Backup and Protection

Pro+

Features

Enjoy the benefits of Pro+ membership, learn more and join.

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

SearchServerVirtualization

SearchCloudComputing

SearchExchange

SearchSQLServer

SearchWinIT

SearchEnterpriseDesktop

SearchVirtualDesktop

Close