Tip

Use VBScript to rename mapped drives

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

    Requires Free Membership to View

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

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

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:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.