Script to remove all network shares

Option Explicit
Dim objNetwork, objShell, strDriveLetter, strDriveLetter2, strDriveLetter3, strDriveLetter4, strDriveLetter5, strDriveLetter6, strDriveLetter7, strDriveLetter8, strDriveLetter9, strDriveLetter10, strDriveLetter11, strDriveLetter12, strDriveLetter13, strDriveLetter14, strDriveLetter15, strDriveLetter16, strDriveLetter17, strDriveLetter18, strDriveLetter19, strDriveLetter20, strDriveLetter21, strDriveLetter22, strDriveLetter23, strDriveLetter24, strDriveLetter25
Dim bForce, bUpdateProfile
strDriveLetter = “e:”
strDriveLetter2 = “d:”
strDriveLetter3 = “e:”
strDriveLetter4 = “f:”
strDriveLetter5 = “g:”
strDriveLetter6 = “h:”
strDriveLetter7 = “i:”
strDriveLetter8 = “j:”
strDriveLetter9 = “k:”
strDriveLetter10 = “l:”
strDriveLetter11 = “m:”
strDriveLetter13 = “n:”
strDriveLetter14 = “o:”
strDriveLetter15 = “p:”
strDriveLetter16 = “q:”
strDriveLetter17 = “r:”
strDriveLetter18 = “s:”
strDriveLetter19 = “t:”
strDriveLetter20 = “u:”
strDriveLetter21 = “v:”
strDriveLetter22 = “w:”
strDriveLetter23 = “x:”
strDriveLetter24 = “y:”
strDriveLetter25 = “z:”
bForce = “True”
bUpdateProfile = “True”
err.number = vbempty
Set objNetwork = CreateObject(“WScript.Network”)
‘ Removes strDriveLetter, with bForce, pUpdate Profile
On Error Resume Next
objNetwork.RemoveNetworkDrive strDriveLetter, bforce, bUpdateProfile
objNetwork.RemoveNetworkDrive strDriveLetter2, bforce, bUpdateProfile
objNetwork.RemoveNetworkDrive strDriveLetter3, bforce, bUpdateProfile
objNetwork.RemoveNetworkDrive strDriveLetter4, bforce, bUpdateProfile
objNetwork.RemoveNetworkDrive strDriveLetter5, bforce, bUpdateProfile
objNetwork.RemoveNetworkDrive strDriveLetter6, bforce, bUpdateProfile
objNetwork.RemoveNetworkDrive strDriveLetter7, bforce, bUpdateProfile
objNetwork.RemoveNetworkDrive strDriveLetter8, bforce, bUpdateProfile
objNetwork.RemoveNetworkDrive strDriveLetter9, bforce, bUpdateProfile
objNetwork.RemoveNetworkDrive strDriveLetter10, bforce, bUpdateProfile
objNetwork.RemoveNetworkDrive strDriveLetter11, bforce, bUpdateProfile
objNetwork.RemoveNetworkDrive strDriveLetter12, bforce, bUpdateProfile
objNetwork.RemoveNetworkDrive strDriveLetter13, bforce, bUpdateProfile
objNetwork.RemoveNetworkDrive strDriveLetter14, bforce, bUpdateProfile
objNetwork.RemoveNetworkDrive strDriveLetter15, bforce, bUpdateProfile
objNetwork.RemoveNetworkDrive strDriveLetter16, bforce, bUpdateProfile
objNetwork.RemoveNetworkDrive strDriveLetter17, bforce, bUpdateProfile
objNetwork.RemoveNetworkDrive strDriveLetter18, bforce, bUpdateProfile
objNetwork.RemoveNetworkDrive strDriveLetter19, bforce, bUpdateProfile
objNetwork.RemoveNetworkDrive strDriveLetter20, bforce, bUpdateProfile
objNetwork.RemoveNetworkDrive strDriveLetter21, bforce, bUpdateProfile
objNetwork.RemoveNetworkDrive strDriveLetter22, bforce, bUpdateProfile
objNetwork.RemoveNetworkDrive strDriveLetter23, bforce, bUpdateProfile
objNetwork.RemoveNetworkDrive strDriveLetter24, bforce, bUpdateProfile
objNetwork.RemoveNetworkDrive strDriveLetter25, bforce, bUpdateProfile
‘ Error correcting code
If err.number = vbEmpty then
Set objShell = CreateObject(“WScript.Shell”)
objShell.run (“Explorer”)
End If

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply