Skip to content

Instantly share code, notes, and snippets.

@mwinandy
Created March 22, 2013 21:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mwinandy/5224966 to your computer and use it in GitHub Desktop.
Save mwinandy/5224966 to your computer and use it in GitHub Desktop.
VB script te rename mapped drive with Windows
' 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