Friday, March 29, 2013

Multiple Drives Mapped With Rename Function


For those who are working as Network Administrator must use Network Drive to map drive for all client computers to access to Drive that share from the server.
We can have several way to to do, like write a net use script ans save as .bat file extension but it's not much flexible as .vbs script when we want to switch the server in the script.
Below is my .vbs script to map drive the client and automatically rename the drive name to what we want without showing the name of server we store file on.


Multiple Drive Mapped with no Rename function




Single Drive Without Rename Drive.
Single Drive With Rename Drive.
Multiple Drives Without Rename Drive, but if you want the multiple Drive with Drive Rename you can use the script below.
Multiple Drives With Rename Drive: Copy Script below, paste into Notepad then save it as .vbs file extension (Ex. mapdrive.vbs)។

‘ Mapping Drive and Rename.vbs
‘ VBScript to map a network drive and rename them.
‘ By Sok Sopheak

‘ —————————————-’
‘\\ServerName\ShareName – “Q:\”
‘\\ServerName\ShareName – “P:\”
‘\\ServerName\ShareName – “Z:\”
Option Explicit
Dim objNetworkP, strDriveP, objShellP
Dim strRemotePathP, strDriveLetterP, strNewNameP
strDriveLetterP = “P:”
strRemotePathP = “\\ServerName\ShareName”
strNewNameP = “New Name that you want to display”
Set objNetworkP = CreateObject(“WScript.Network”)
objNetworkP.MapNetworkDrive strDriveLetterP, strRemotePathP
Set objShellP = CreateObject(“Shell.Application”)
objShellP.NameSpace(strDriveLetterP).Self.Name = strNewNameP
Dim objNetworkZ, strDriveZ, objShellZ
Dim strRemotePathZ, strDriveLetterZ, strNewNameZ
strDriveLetterZ = “Z:”
strRemotePathZ = “\\ServerName\ShareName”
strNewNameZ = “New Name that you want to display”
Set objNetworkZ = CreateObject(“WScript.Network”)
objNetworkZ.MapNetworkDrive strDriveLetterZ, strRemotePathZ
Set objShellZ = CreateObject(“Shell.Application”)
objShellZ.NameSpace(strDriveLetterZ).Self.Name = strNewNameZ
Dim objNetworkQ, strDriveQ, objShellQ
Dim strRemotePathQ, strDriveLetterQ, strNewNameQ
strDriveLetterQ = “Q:”
strRemotePathQ = “\\ServerName\ShareName”
strNewNameQ = “New Name that you want to display”
Set objNetworkQ = CreateObject(“WScript.Network”)
objNetworkQ.MapNetworkDrive strDriveLetterQ, strRemotePathQ
Set objShellQ = CreateObject(“Shell.Application”)
objShellQ.NameSpace(strDriveLetterQ).Self.Name = strNewNameQ
WScript.Quit
‘ End of Example VBScript.

Multiple Drive Mapped with Rename function




Thanks to Mr. Sok Sopheak for the scrip editing.

No comments:

Post a Comment