In my previous post, I described how to connect to a network drive.
In this post, I will demonstrate how to disconnect from an existing connected network drive.
Suppose we have a drive Z: that is a network drive connected. Following is the code regarding how ti remove it.
Dim WshNetwork, ShareName
Set WshNetwork = WScript.CreateObject("WScript.Network")
ShareName = "Z:"
WshNetwork.RemoveNetworkDrive ShareName, true, true
We are creating an object of WScript.Network and calling method RemoveNetworkDrive by passing the drive letter.