|
MapDrv
Here's a script that lets you map and un-map a network drive with just one click:
'Here's an example of a more complex script.
'Let's say you use a portable computer that is sometimes connected to a local-area network.
'While the process of mapping and disconnecting a network drive is not difficult, it can be tedious to do repeatedly.
Set WshShell = WScript.CreateObject("WScript.Shell")
Set WshNetwork = WScript.CreateObject("WScript.Network")
Set AllDrives = WshNetwork.EnumNetworkDrives()
DriveLetter = "N:" ' must be CAP
RemotePath = "\\MAXI\c$"
AlreadyConnected = False
For i = 0 To AllDrives.Count - 1 Step 2
If AllDrives.Item(i) = DriveLetter Then AlreadyConnected = True
Next
If AlreadyConnected = False then
WShNetwork.MapNetworkDrive DriveLetter, RemotePath
Msgbox "Drive " & DriveLetter & " connected successfully."
Else
WShNetwork.RemoveNetworkDrive DriveLetter
Msgbox "Drive " & DriveLetter & " disconnected."
End if
|