Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exporting ODBC System DSNs from a windows 2003 machine?

Is there a way to export all the ODBC System DSNs from a windows 2003 machine?

like image 240
Zaffiro Avatar asked Feb 04 '11 20:02

Zaffiro


People also ask

Which SQL command returns the list of registered DSNs?

INI\ODBC DATA SOURCES, and then returns the names and values of the all the registry entries found there. Each entry will consist of a name (representing the DSN name) and a value (representing the DSN driver).


3 Answers

System DSN information is stored under the HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI registry key. You could export that key to a .reg file and import on another machine.

UPDATE:

You can also do it programmatically. Here are a few examples:

http://www.codeproject.com/KB/database/DSNAdmin.aspx

http://support.microsoft.com/kb/110507

http://blogs.technet.com/b/heyscriptingguy/archive/2004/11/10/can-i-create-and-delete-a-dsn-using-a-script.aspx

like image 100
Garett Avatar answered Sep 28 '22 20:09

Garett


I have just done this myself with a very simple bat script for 32bit ODBC sources

regedit /e c:\backup\odbc.reg "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ODBC\ODBC.INI"

and for the 64bit sources or if you are on a 32bit operating system:

regedit /e c:\backup\odbc.reg "HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI"

This backs up all of the DSN's however you could then specify the DNS you want.

like image 39
Phil Hannent Avatar answered Sep 28 '22 22:09

Phil Hannent


System DSN's are stored in windows registry under HKLM\Software\ODBC\ODBC.INI node So if you export this node to a *.reg file and run this reg file on a target machine, it should work.

The only thing, this reg file will contain some file paths which maybe computer specific, eg c:\WINNT\System32\bla-bla-bla.dll includes WINNT folder which on target machine may be called like WINDOWS. So you will need to spend a bit time to make sure all paths in *.reg file are correct for target machine where you would finally import.

like image 20
ayush Avatar answered Sep 28 '22 22:09

ayush