All Forums >> [Scripting] >> WSH & Client Side VBScript >> remove all network drives and printers at logon Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
It seems to pick up only one of my network drives and doesnt delete it anyway. It misses about 5 others. Can you show me an example before my pc goes through the window.
Okay worked it out myself. To delete all printer connections (not local) and remove all mapped drives, the code is as follows
______________________________
On error resume next
Set WshNetwork = WScript.CreateObject("WScript.Network") Set oDrives = WshNetwork.EnumNetworkDrives Set oPrinters = WshNetwork.EnumPrinterConnections For i = 0 to oDrives.Count - 1 Step 2 WshNetwork.RemoveNetworkDrive oDrives.Item(i),true,true Next For i = 0 to oPrinters.Count - 1 Step 2 WScript.Echo oPrinters.Item(i+1) WshNetwork.RemovePrinterConnection oPrinters.Item(i+1)