Created
March 22, 2013 21:37
-
-
Save mwinandy/5224966 to your computer and use it in GitHub Desktop.
VB script te rename mapped drive with Windows
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' NameDrive.vbs | |
' VBScript to map a network drive. | |
' Last Author Maxence Winandy <maxence.winandy@gmail.com> | |
' Original Authors Guy Thomas and Barry Maybury | |
' ----------------------------------------' | |
' | |
' Usage: >cscript "<\\%network place to mount>" "<Drive Letter>" "<Name of drive>" | |
Option Explicit | |
Dim objNetwork, strDrive, objShell, objUNC | |
Dim strRemotePath, strDriveLetter, strNewName | |
' | |
strDriveLetter = WScript.Arguments.Item(1) & ":" | |
strRemotePath = WScript.Arguments.Item(0) | |
strNewName = WScript.Arguments.Item(2) | |
' 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment