' this script disconnects all network drives L_Welcome_MsgBox_Title_Text = "Network Drive Zapper" ' ******************************************************************************** ' * ' * WSH Network Object. ' * Dim WSHNetwork Dim colDrives, SharePoint Dim CRLF CRLF = Chr(13) & Chr(10) Set WSHNetwork = WScript.CreateObject("WScript.Network") 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) Next MsgBox "All network drives disconnected", _ vbInformation + vbOkOnly, _ L_Welcome_MsgBox_Title_Text End If End If