add

Tuesday, September 8, 2009

How to disconnect a map drive using vbscript

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.


Option Explicit
Dim WshNetwork, ShareName
Set WshNetwork = WScript.CreateObject("WScript.Network")
ShareName = "Z:"
WshNetwork.RemoveNetworkDrive ShareName, true, true
WScript.Quit


We are creating an object of WScript.Network and calling method RemoveNetworkDrive by passing the drive letter.

No comments: