Solved

Logon script doesn't replace mapped network share

Posted on 2006-06-10
7
290 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 1

Author Comment

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

Author Comment

by:Dan_Mahoney
Comment Utility
Both trues does the trick. Thanks!
0
 
LVL 51

Expert Comment

by:Netman66
Comment Utility
You're welcome!

NM
0
 
LVL 51

Expert Comment

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

0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

I have never ceased to be amazed how many problems you can encounter on a fresh install of a Windows operating system.  This is certainly case in point& Unable to complete ANY MSI installation.  This means Windows Updates are failing and I can't …
So you have two Windows Servers and you have a directory/folder/files on one that you'd like to mirror to the other?  You don't really want to deal with DFS or a 3rd party solution like Doubletake. You can use Robocopy from the Windows Server 200…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

744 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

14 Experts available now in Live!

Get 1:1 Help Now