Solved

VB Login Script Change drive Mapping

Posted on 2006-07-21
4
766 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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 utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

707 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

11 Experts available now in Live!

Get 1:1 Help Now