[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 778
  • Last Modified:

VB Login Script Change drive Mapping

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
compdigit44
Asked:
compdigit44
  • 2
  • 2
2 Solutions
 
JRCSystemsCommented:
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
 
compdigit44Author Commented:
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
 
JRCSystemsCommented:
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
 
compdigit44Author Commented:
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

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now