Solved

VB Login Script Change drive Mapping

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

930 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