Migrating ODBC information through a batch file

Solution 1:

Yes, you're on the right track. There are actually two registry keys you'll be interested in depending on if you've set custom TCP ports for the ODBC connections, etc:

HKLM\SOFTWARE\Wow6432Node\ODBC\ODBC.INI\

HKLM\SOFTWARE\Wow6432Node\Microsoft\MSSQLServer\Client\

HKLM is where System DSNs are stored. HKCU is where User DSNs are stored for the current user.

The Wow6432Node part will only be present if you are looking at 32bit ODBC entries on a 64bit system. If you are looking at 32bit ODBC entries on a 32bit system, you will not see the Wow6432Node folder. If you are looking at 64bit ODBC entries on a 64bit system, you will not see the Wow6432Node folder. (You can substitute "32bit on 32bit" and "64bit on 64bit" for the word "native.") You can run 32bit code on a 64bit computer but it is not considered "native."

If you are exporting the ODBC entries from a 32bit platform and importing them into a 64 bit OS, you will need to put them in the appropriate place under the Wow6432Node folder.

To see this another way, get on a 64bit Windows 7 computer. Run Windows\System32\odbcad32.exe. That is the native (64bit version.) Add an ODBC connection in there.

Now run Windows\SysWOW64\odbcad32.exe on the same machine. That is the 32bit version (WoW64 stands for Win32 Emulation on 64bit Windows.) You will notice that the ODBC connection that you created is not there. Because you're not looking at native ODBC connections anymore. You're looking at 32bit ones.

That is why you have to pay attention to the architecture that the ODBC connection is coming from, and the architecture that you're importing it to.

edit: My explanation is probably about as clear as mud, but if you want a better explanation of file system redirection and registry redirection for 32bit processes running on 64bit Windows, I highly suggest Windows Internals, 6th Ed. by Mark Russinovich, et al. Part I, Chapter 3.

edit #2: No you cannot just copy the registry keys to both places and hope to cactch everything. The system will prefer the native ones, which will not work if they needed to be in the 32bit context.