Solved

VB Login Script Change drive Mapping

Posted on 2006-07-21
4
769 Views
Last Modified: 2008-02-01
Let me start out by saying I'm very weak in vbscripting. Ok, here is what I need to do. I need a login script that will edit the following registry key: HKEY_Current_User\Network. I'm in the process of migrating from one file server to another and a lot of my users have manual drive mapping. I need to script to detect the old server name and replace it with the new server name while keeping the same drive letter. So it's transparent to the user. Thanks in advance.
0
Comment
Question by:compdigit44
  • 2
  • 2
4 Comments
 
LVL 4

Assisted Solution

by:JRCSystems
JRCSystems earned 385 total points
ID: 17159590
I am not sure of a few things here.

1. Why does it have to be a script, as opposed to a VB program?
2. What OS(es) are you running? All the same? mixed?

Here's the reason(s) I ask:

I believe starting with Win 2K (not sure about 98), administrators could connect to remote registries.

VB, has that same ability to OPEN / EDIT a registry on a remote computer (providing OS allows it).

I am not sure of the specifics of your office, but it seems you'd have to loop through HKEY_USERS on the machine,
assuming there's more than 1 user account with the redirect/drive mapping.

You weren't specific on the drive letter, or the old server name, new server name, but in general, you have something that did this:

Read registry key(s)
HKEY_USERS\[user guid WITHOUT _classes]\Network\[Drive Letter]
Edit "RemotePath" = \\[newservername]\[sharename]

Again, depending on the OSes there, VB could even loop through all computers on the network, connect to each registry, edit/save, continue.

It would avoid the login script scenario.

-----------

Then again, there is 1 solution that doesn't involve any programming:
rename the "oldserver" to olderServer2"
rename the "newserver" to "oldserver"
have everyone reboot. no programming changes, everyone is pointing to the new server.


Hope that helps.



0
 
LVL 19

Author Comment

by:compdigit44
ID: 17160829
Sorry for the lack of information. I have 95 desktops, 80 are running Windows XP professional 15 are still running Windows 2000 professional. I still have a NT 4.0 domain, which I'm currently in the process of migrating. So connecting to each of these desktop wouldn't be very efficient. Renaming the servers would be great but isn't an option for me either. Is there some way in the VB script you can tell it to look at the remote path in the registry and use an 'if' statement? So if old_server_name is present change to new_server_name????
0
 
LVL 4

Accepted Solution

by:
JRCSystems earned 385 total points
ID: 17162983
Yes, there is a way to read the remote registry, check its value, and change it.

I have got a Class file I could send you that you'd need to implement in your program.
The module is about 800 lines of code. It did not seem right to post that as the answer, with no explanation.
I've used this class library for about the last 4 years. It original came from VB2theMax, and got various updates.


Inside the class, there are 2 key methods:
ReadRemoteRegistryValue and WriteRemoteRegistryValue.

Those methods, tied to your "IF" statement checking the server name, will solve the problem.





0
 
LVL 19

Author Comment

by:compdigit44
ID: 17163769
Thanks the the feed back everyone. In my efforts of having a low impact on the end users enviroment may quest for a script to move user from one server to another have become very complex. I have to admit some of the VB replys are way beyond my VB script knownledge. I'm most likely going to send out a batch script that will disconnect everyones mapped drive then reconnect them to a different drive letter. This way everyone will have uniform network drive mappings.
 
0

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

773 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