Logon script doesn't replace mapped network share

My intention with this script is to re-map the user's drive mappings to a new server. We are retiring an old file server and copying user and community files to a new server. This script does a wonderful job of mapping drives if they have not been previously mapped and disconnecting previously mapped drives. It won't replace the old U: drive mapping with the new one; it only disconnects it and leaves it mapped to the old share. This is the script:

Dim objADSysInfo, objUser, objNetwork
Dim strComputer, strDriveUser, strDriveCC, strCNUser, strUserLogon

On Error Resume Next

strComputer = "TEAK"
strDriveUser = "U:"
strDriveCC = "L:"

Set objADSysInfo = CreateObject("ADSystemInfo")
strCNUser = objADSysInfo.UserName

Set objUser = GetObject("LDAP://" & strCNUser)
strUserLogon = objUser.sAMAccountName

Set objNetwork = WScript.CreateObject("Wscript.Network")
objNetwork.RemoveNetworkDrive strDriveUser, True
objNetwork.MapNetworkDrive strDriveUser, "\\" & strComputer & "\" & strUserLogon
objNetwork.RemoveNetworkDrive strDriveCC, True
objNetwork.MapNetworkDrive strDriveCC, "\\" & strComputer & "\Campus_Center"

Help with this would be great. Thanks in advance.
Who is Participating?

Improve company productivity with a Business Account.Sign Up

Netman66Connect With a Mentor Commented:
If you MUST use brute force, then you need an additional TRUE.

objNetwork.RemoveNetworkDrive strDriveCC, True, True

Like that.

This line:  objNetwork.RemoveNetworkDrive strDriveUser, True

Should be:  objNetwork.RemoveNetworkDrive strDriveUser


This line:  objNetwork.RemoveNetworkDrive strDriveCC, True

Should be:  objNetwork.RemoveNetworkDrive strDriveCC

Dan_MahoneyAuthor Commented:
Thank you for looking at this.

I think I have tried both of your suggestions and thought that I was not getting the results I wanted. I try again. First no true and second both trues.
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Dan_MahoneyAuthor Commented:
The no trues produced the Disconnected network drive I have experienced before.
Dan_MahoneyAuthor Commented:
Both trues does the trick. Thanks!
You're welcome!

The second true updates the profile (where the mappings are stored for network drives).

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.