remove network drives in a vb script

I have a VB script that connects my network drives without a problem. I added a section so i can remove certain drive letters and where they map to. I need to do this so i can remap the drives somewhere else the section i added to do the remove is below but it is not working.

Dim sUserID
Dim oGroup
Dim oNet
Dim colDrives
Dim sDomainName
Const E_ADS_PROPERTY_NOT_FOUND  = &h8000500D


Set oNet = CreateObject("Wscript.Network")
sUserID = ""
On Error Resume Next
Do While sUserID = ""
  sUserID = oNet.UserName
Loop
On Error Goto 0
'wscript.echo sUserid

DriveMap()


Sub DriveMap()

'Remove mapped drives

On Error Resume Next
'oNet.RemoveNetworkDrive "E:"
'oNet.RemoveNetworkDrive "F:"
'oNet.RemoveNetworkDrive "G:"
'oNet.RemoveNetworkDrive "H:"
'oNet.RemoveNetworkDrive "I:"
'oNet.RemoveNetworkDrive "J:"
'oNet.RemoveNetworkDrive "K:"
'oNet.RemoveNetworkDrive "M:"
'oNet.RemoveNetworkDrive "N:"
'oNet.RemoveNetworkDrive "O:"
'oNet.RemoveNetworkDrive "P:"
'oNet.RemoveNetworkDrive "Q:"
'oNet.RemoveNetworkDrive "R:"
oNet.RemoveNetworkDrive "u:"

AllosITAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Shift-3Commented:
Do you have an End Sub at the end of that?  What do get if you comment out the On Error Resume Next?

It might be simplest to use the script from this article to remove all network drives, and then map the ones you want.
http://www.microsoft.com/technet/scriptcenter/resources/qanda/sept05/hey0915.mspx
0
AllosITAuthor Commented:
Yes i do have an End Sub. If I comment out the On Error Resume Next, I get the following VB script error:

Line: 39
Char: 1
Error: This network connection does not exist
Which is this line oNet.RemoveNetworkDrive "u:"
Here is a funny thing if i open the u drive before i run the script the it does not error and just disconnects the drive mapping but does not remove it.


0
Shift-3Commented:
Try changing that line to
oNet.RemoveNetworkDrive "u:", True, True

This forces removal and also removes it from the user's profile.  See here for the full syntax:
http://msdn.microsoft.com/en-us/library/d16d7wbf(VS.85).aspx
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
AllosITAuthor Commented:
Thanks for all your help
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Smartphones

From novice to tech pro — start learning today.