从 Windows 2003 计算机导出 ODBC 系统 DSN?
有没有办法从 Windows 2003 计算机导出所有 ODBC 系统 DSN?
Is there a way to export all the ODBC System DSNs from a windows 2003 machine?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
系统 DSN 信息存储在
HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI
注册表项下。您可以将该密钥导出到 .reg 文件并导入到另一台计算机上。更新:
您也可以通过编程方式完成此操作。以下是一些示例:
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
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
我刚刚自己使用一个非常简单的 bat 脚本完成了此操作,适用于 32 位 ODBC 源
和 64 位源,或者如果您使用的是 32 位操作系统:
这会备份所有 DSN,但是您可以指定所需的 DNS。
I have just done this myself with a very simple bat script for 32bit ODBC sources
and for the 64bit sources or if you are on a 32bit operating system:
This backs up all of the DSN's however you could then specify the DNS you want.
系统 DSN 存储在
HKLM\Software\ODBC\ODBC.INI
节点下的 Windows 注册表中因此,如果您将此节点导出到 *.reg 文件并在目标计算机上运行此 reg 文件,它应该可以工作。
唯一的事情是,这个 reg 文件将包含一些可能特定于计算机的文件路径,例如
c:\WINNT\System32\bla-bla-bla.dll
包含 WINNT 文件夹,该文件夹在目标计算机上可能被称为WINDOWS
。因此,您需要花一些时间来确保 *.reg 文件中的所有路径对于您最终导入的目标计算机都是正确的。System DSN's are stored in windows registry under
HKLM\Software\ODBC\ODBC.INI
nodeSo 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 likeWINDOWS
. 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.我编写了一些 Powershell 函数,用于将 ODBC 连接从一台计算机复制到另一台计算机,它们发布(并不断更新)于:
http://powershell.com/cs/media/p/32510.aspx
结合使用这些函数,您可以将一台计算机的所有 ODBC 连接复制到另一台计算机:
$srcConfig = Get-OdbcConfig srcComputerName
Import-OdbcConfig trgComputerName $scrConfig
通过过滤路径,可以仅包含您最喜欢的 ODBC 连接:
或过滤掉您不喜欢的 ODBC 连接:
Import-OdbcConfig 仅在设置值时返回数据,或者无法 ping 目标(如果存在)没有什么可以创造它不会说什么。
I wrote some Powershell functions for copying ODBC connections from one computer to another, they are posted (and kept updated) at:
http://powershell.com/cs/media/p/32510.aspx
Using these functions together you can copy all of one computers ODBC connections to another:
$srcConfig = Get-OdbcConfig srcComputerName
Import-OdbcConfig trgComputerName $scrConfig
It's possible to include only your favorite ODBC connection by filtering on the path:
Or filtering out ODBC connections you don't like:
Import-OdbcConfig only returns data when setting values or can't ping target, if there's nothing to create it won't say anything.
如果您在那里找不到注册,根据它们是否是用户 DSN/系统 DSN,它们很可能位于:
If you can't find the registrations there, depending on if they are User DSN/System DSN, they can very will be in: