TheSwamp
Code Red => VB(A) => Topic started by: Kheilmann on December 22, 2006, 03:53:13 PM
-
Is it possible to map & disconnect a \\Server\Folder\ to/from a drive letter?
-
this might get you started
Set WshShell = WScript.CreateObject("WScript.Shell")
Set WshNetwork = WScript.CreateObject("WScript.Network")
Set AllDrives = WshNetwork.EnumNetworkDrives()
DriveLetter = "N:" 'must be capitalized
RemotePath = "\\server\share"
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
WshShell.PopUp "Drive " & DriveLetter & " connected successfully."
Else
WShNetwork.RemoveNetworkDrive DriveLetter
WshShell.PopUp "Drive " & DriveLetter & " disconnected."
End if
-
Is it possible to map & disconnect a \\Server\Folder\ to/from a drive letter?
YES.
Sorry, could not resist. I have a whole app that does this. You can use an INI file to load the paths you want and then map and unmap which ones you want by checking the boxes. Let me know if you are interested and I will see if I can find the code.