• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 306
  • Last Modified:

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.
0
Dan_Mahoney
Asked:
Dan_Mahoney
  • 4
  • 3
1 Solution
 
Netman66Commented:
This line:  objNetwork.RemoveNetworkDrive strDriveUser, True

Should be:  objNetwork.RemoveNetworkDrive strDriveUser

AND

This line:  objNetwork.RemoveNetworkDrive strDriveCC, True

Should be:  objNetwork.RemoveNetworkDrive strDriveCC


NM
0
 
Netman66Commented:
If you MUST use brute force, then you need an additional TRUE.

objNetwork.RemoveNetworkDrive strDriveCC, True, True

Like that.

0
 
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.
0
Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

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

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

0

Featured Post

[Webinar] Improve your customer journey

A positive customer journey is important in attracting and retaining business. To improve this experience, you can use Google Maps APIs to increase checkout conversions, boost user engagement, and optimize order fulfillment. Learn how in this webinar presented by Dito.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now