
Originally Posted by
apeo
If you leave option explicit in then you need to define every variable before you use it so if you run the script in its current format, yes it wont work. Also the 'on error resume next', well thats selfexplanatory.
Turbo! I didn't fully understand what 'option explicit' did. Without that in (I'm sure I tried it before but hey...!) it worked. I also had to add another 'on error resume' to the removedrives sub routine to ensure that all existing drives were removed.
Code:
sub RemoveNetworkDrives
Dim NetDrives
Dim i
Set WSHNetwork = WScript.CreateObject("WScript.Network")
Set NetDrives = WSHNetwork.EnumNetworkDrives
On Error Resume Next
If NetDrives.Count <> 0 Then
For i = 0 To NetDrives.Count - 1
WSHNetwork.RemoveNetworkDrive NetDrives(i)
Next
End If
end sub Thanks very much for all your help! I'll upload the complete script for future reference when I've tidied it up a bit.
Dave.