Richard
Wed Aug 27 20:03:12 CDT 2003
Jason Hill wrote:
> I have already writen my login script in vbs to map network drives. In
> windowsXP under an active directory with a group policy, what is the
correct
> syntax for a VBS file to UNmap network drives?
>
Hi,
The WshNetwork object has a RemoveNetworkDrive method. For example, I use
the code below in a logon script. If a share is already mapped to M:, the
MapNetworkDrive method fails, so I remove the mapping and try again:
Set objNetwork = CreateObject("Wscript.Network")
On Error Resume Next
Err.Clear
objNetwork.MapNetworkDrive "M:", "\\filesrv01\admin"
If Err.Number <> 0 Then
Err.Clear
On Error GoTo 0
objNetwork.RemoveNetworkDrive "M:", True, True
objNetwork.MapNetworkDrive "M:", "\\filesrv01\admin"
End If
On Error GoTo 0
In my logon script I do not make the mapping persistent, so I don't have to
remove the mapping at logoff. However, you could unmap with
RemoveNetworkDrive. The first True in the RemoveNetworkDrive method says to
remove it even if it is in use. The second True says to make the removal
persistent.
--
Richard
Microsoft MVP Scripting and ADSI
HilltopLab web site -
http://www.rlmueller.net
--