Option Explicit Dim objNetwork, objShell Dim sPath, sDrive, sName, sFileName Dim objFile, sLine, sMapping ' This script maps network drives, based on an argument passed at the command line ' The text file passed as argument 0 needs to be plain text, with a drive to map on ' each line. The lines need to be pipe-separated (|), in the format: ' DriveLetter | UNC Path to map | Name to be assigned to mapping On Error Resume Next ' Read the text file name from the command line sFileName = WScript.Arguments.Item(0) ' Set up the objFile object to open the file Set objFile = CreateObject("Scripting.FileSystemObject").OpenTextFile(sFileName,1) ' Open the text file and start looping one line at a time do while not objFile.AtEndOfStream ' Read the next line sLine = objFile.ReadLine() ' Each line in the file represents a mapping. The 'fields' of the mapping should ' be separated by the same character (",", "|", ";" are reasonable choices) sMapping = Split(sLine, "|") ' Onec the line is split apart, asign each part to its own variable sDrive = sMapping(0) & ":" sPath = sMapping(1) sName = sMapping(2) 'If things aren't working, this next MsgBox line can be useful 'MsgBox ("Drive = " & sDrive & ", name = " & sName & ", path = " & sPath) ' Set up the WScript Network object Set objNetwork = CreateObject("WScript.Network") ' Remove an old drive mapping, if it exists objNetwork.RemoveNetworkDrive sDrive ' Map the new drive, with the preferred letter and path objNetwork.MapNetworkDrive sDrive, sPath ' Set up a Shell object to use in renaming the drive Set objShell = CreateObject("Shell.Application") ' Rename the drive as preferred objShell.NameSpace(sDrive).Self.Name = sName loop ' Clean up objects and quit objFile.Close Set objFile = Nothing WScript.Quit