RemoveNetworkDrive Method

Removes a shared network drive from your computer system.

Syntax

object.RemoveNetworkDrive(strName, [bForce], [bUpdateProfile])

Arguments

  • object
    WshNetwork object.

  • strName
    String value indicating the name of the mapped drive you want to remove. The strName parameter can be either a local name or a remote name depending on how the drive is mapped.

  • bForce
    Optional. Boolean value indicating whether to force the removal of the mapped drive. If bForce is supplied and its value is true, this method removes the connections whether the resource is used or not.

  • bUpdateProfile
    Optional. String value indicating whether to remove the mapping from the user's profile. If bUpdateProfile is supplied and its value is true, this mapping is removed from the user profile. bUpdateProfile is false by default.

Remarks

If the drive has a mapping between a local name (drive letter) and a remote name (UNC name), then strName must be set to the local name. If the network path does not have a local name (drive letter) mapping, then strName must be set to the remote name.

Legacy Code Example

The following code removes the logical drive "E."

Dim WshNetwork
Set WshNetwork = WScript.CreateObject("WScript.Network")
WshNetwork.RemoveNetworkDrive "E:"
var WshNetwork = WScript.CreateObject("WScript.Network");
WshNetwork.RemoveNetworkDrive ("E:");

Applies To:

WshNetwork Object

See Also

EnumNetworkDrives Method
MapNetworkDrive Method