Re: Disconnect connection setup via "net use \\server\share"
- From: "Ato Bisda" <atobisda@xxxxxxxxx>
- Date: Fri, 22 Jul 2005 14:10:25 -0400
Hello,
Without going through the details of your script, wouldn't an "ON ERROR RESUME NEXT" solve your
problem?
Regards,
Ato
"Kevin" <Kevin@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:BA33F41D-3A44-4CE2-B8CF-927EEA5150B1@xxxxxxxxxxxxxxxx
> I'm using the following script to disconnect mapped network drives, which
> works fine except when there is no local drive mapped to the resource. If I
> run the script, it errors out saying that the parameter is incorrect
> (provided I have a non-mapped connection). If I delete the connection that
> is not associated with a local drive, it works great.
> How do I go about checking for these connections on a client computer, and
> disconnecting them?
>
> Here is the script I'm using now.
>
> Function Ask(strAction)
>
> ' This function asks the user whether to perform a specific "Action"
> ' and sets a return code or quits script execution depending on the
> ' button that the user presses. This function is called at various
> ' points in the script below.
>
> Dim intButton
> intButton = MsgBox(strAction, _
> vbQuestion + vbYesNo, _
> L_Welcome_MsgBox_Title_Text )
> Ask = intButton = vbYes
> End Function
>
> 'ask user if he/she is sure he/she wants to disconnect all network drives
> If Ask("Do you wish to disconnect all network drives?") Then
> 'Enumerate network drives into a collection object of type WshCollection
> Set colDrives = WSHNetwork.EnumNetworkDrives
>
> 'If no network drives were enumerated, then inform user, else disconnect
> 'enumerated drives
> If colDrives.Count = 0 Then
> MsgBox "There are no network drives to disconnect.", _
> vbInformation + vbOkOnly, _
> L_Welcome_MsgBox_Title_Text
> Else
> For i = 0 To colDrives.Count - 1 Step 2
> WshNetwork.RemoveNetworkDrive colDrives(i), True, True
> Next
>
> MsgBox "All network drives disconnected",
> _
> vbInformation + vbOkOnly, _
> L_Welcome_MsgBox_Title_Text
>
> End If
>
> End If
>
> I have another script that will pickup these connections, but other than by
> drive letter, I'm not sure how to reference the connection. Thanks in advance
.
- Follow-Ups:
- References:
- Prev by Date: Re: Modifying a script (rookie) - Delete all files in a folder
- Next by Date: RE: Modifying a script (rookie) - Delete all files in a folder
- Previous by thread: Disconnect connection setup via "net use \\server\share"
- Next by thread: Re: Disconnect connection setup via "net use \\server\share"
- Index(es):