| 3TGKB-0051 | |
|
Last Edited : |
06-07-05 |
|
Revision : |
1.0 |
How do I map a drive letter and control the way Windows names it?
There I was with the client, gloating at how my logon script mapped G drive
to \\London\Data only to have the client say “I don’t like the way it calls it
‘Data on London’. I want it called ‘Shared Data’.” I could feel the bile rising
as I smiled and politely replied “I should be able to do that….” Cursing under
my breath that this LUSER wants to take up my valuable time on such inane
pursuits I walked back to my laptop to see if Google had any answers. And strike
me lucky it did!!

Here is the VBScript to make the above magic happen:
' RenameGDrive.vbs
' VBScript to map G drive to \\London\Data but call it “Shared Data” rather than
“Data on London”.
' Author: Paul Eddington, who used original code written by Guy Thomas and Barry
Maybury
' Version 1.0 - July 2005
' ----------------------------------------'
'
Option Explicit
Dim objNetwork, strDrive, objShell, objUNC
Dim strRemotePath, strDriveLetter, strNewName
'
strDriveLetter = "G:"
strRemotePath = "\\London\Data"
strNewName = "Shared Data"
' 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.Quit
' End of VBScript.
Paul Eddington
KB Keywords: mapped drive rename display alias pain-in-the-ass-client