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.

1 comment:

lee woo said...

Panic causes tunnel vision. Calm acceptance of danger allows us to more easily assess the situation and see the options. See the link below for more info.


#options
www.ufgop.org