WshNetwork.MapNetworkDrive
Add a shared network drive mapping.
Syntax
WshNetwork.MapNetworkDrive(strLocalDrive, strRemoteShare, [persistent], [strUser], [strPassword])
Options:
strLocalDrive : The drive letter (e.g. L:)
strRemoteShare : The UNC path to the remote drive \\MyServer\MyPrinter
(String value)
persistent : True/False - store the mapping persistently in the users profile
default = false
strUser : The user name. (Optional)
strPassword : The password. (Optional)
Example
Dim objNetwork
Set objNetwork = WScript.CreateObject("WScript.Network")
strLocalDrive = "H:"
strRemoteShare = "\\myserver\users"
objNetwork.MapNetworkDrive strLocalDrive, strRemoteShare, False
WshNetwork.EnumNetworkDrives
Enumerate Network Drives.
Syntax
WshNetwork.EnumNetworkDrives
Example
Set WshNetwork = WScript.CreateObject("WScript.Network")
Set oDrives = WshNetwork.EnumNetworkDrives
For i = 0 to oDrives.Count - 1 Step 2
WScript.Echo "Drive " & oDrives.Item(i) & " = " & oDrives.Item(i+1)
Next
WshNetwork.RemoveNetworkDrive
Remove a shared network drive mapping.
Syntax
WshNetwork.RemoveNetworkDrive(strName, [bForce], [bUpdateProfile])
options:
strName : The mapped drive you want to remove.
bForce : Force the removal of the mapped drive (TRUE/FALSE).
bUpdateProfile : Remove the mapping from the user's profile (TRUE/FALSE).
Example
Dim WshNetwork
Set WshNetwork = CreateObject("WScript.Network")
WshNetwork.MapNetworkDrive "I:", "\\print_server\hp_01","True","jdoe","jdoepassword"
WshNetwork.RemoveNetworkDrive "I:"