Solved

Logon script doesn't replace mapped network share

Posted on 2006-06-10
7
291 Views
Last Modified: 2010-04-18
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
Comment
Question by:Dan_Mahoney
  • 4
  • 3
7 Comments
 
LVL 51

Expert Comment

by:Netman66
ID: 16882431
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
 
LVL 51

Accepted Solution

by:
Netman66 earned 500 total points
ID: 16882435
If you MUST use brute force, then you need an additional TRUE.

objNetwork.RemoveNetworkDrive strDriveCC, True, True

Like that.

0
 
LVL 1

Author Comment

by:Dan_Mahoney
ID: 16887377
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
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 
LVL 1

Author Comment

by:Dan_Mahoney
ID: 16887444
The no trues produced the Disconnected network drive I have experienced before.
0
 
LVL 1

Author Comment

by:Dan_Mahoney
ID: 16887604
Both trues does the trick. Thanks!
0
 
LVL 51

Expert Comment

by:Netman66
ID: 16887618
You're welcome!

NM
0
 
LVL 51

Expert Comment

by:Netman66
ID: 16888172
The second true updates the profile (where the mappings are stored for network drives).

0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Learn about cloud computing and its benefits for small business owners.
Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now