Difference between revisions of "ODBC Connection"
From WPKG | Open Source Software Deployment and Distribution
Line 2: | Line 2: | ||
==A WPKG Package to create an ODBC Connection== | ==A WPKG Package to create an ODBC Connection== | ||
+ | ===The Installer Package=== | ||
<pre> | <pre> | ||
<package id="ODBC_CONN_X" | <package id="ODBC_CONN_X" | ||
Line 25: | Line 26: | ||
<check type="registry" condition="equals" path="HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI\ODBC Data Sources\%ODBC_DSN_NAME%" value="%ODBC_DRIVERNAME%" /> | <check type="registry" condition="equals" path="HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI\ODBC Data Sources\%ODBC_DSN_NAME%" value="%ODBC_DRIVERNAME%" /> | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
<install cmd="xcopy /Y "%WPKGHOME%\ODBC\%ODBC_TEMPLATE_FILE%" "%LOCALDOWNLOADS%\"" /> | <install cmd="xcopy /Y "%WPKGHOME%\ODBC\%ODBC_TEMPLATE_FILE%" "%LOCALDOWNLOADS%\"" /> | ||
<install cmd="%tools%\TxtReplace\TxtReplace.exe -i "%LOCALDOWNLOADS%\%ODBC_TEMPLATE_FILE%" -r __ODBC_DSN_NAME__ "%ODBC_DSN_NAME%" -r __ODBC_DESCRIPTION__ "%ODBC_DESC%" -r __ODBC_DBSERVER__ "%ODBC_DBSERVER%" -r __ODBC_DBNAME__ "%ODBC_DBNAME%" " /> | <install cmd="%tools%\TxtReplace\TxtReplace.exe -i "%LOCALDOWNLOADS%\%ODBC_TEMPLATE_FILE%" -r __ODBC_DSN_NAME__ "%ODBC_DSN_NAME%" -r __ODBC_DESCRIPTION__ "%ODBC_DESC%" -r __ODBC_DBSERVER__ "%ODBC_DBSERVER%" -r __ODBC_DBNAME__ "%ODBC_DBNAME%" " /> | ||
Line 42: | Line 35: | ||
</package> | </package> | ||
+ | </pre> | ||
+ | |||
+ | ===The Registry Template=== | ||
+ | |||
+ | This requires "TxtReplace.exe" substitution utility, and "reg.exe" from the Windows 2000 resource kit (on the W2K CD) | ||
+ | |||
+ | <pre> | ||
+ | Windows Registry Editor Version 5.00 | ||
+ | |||
+ | [HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI\ODBC Data Sources] | ||
+ | "__ODBC_DSN_NAME__"="SQL Server" | ||
+ | |||
+ | [HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI\__ODBC_DSN_NAME__] | ||
+ | "Driver"="C:\\WINDOWS\\system32\\SQLSRV32.dll" | ||
+ | "Description"="__ODBC_DESCRIPTION__" | ||
+ | "Server"="__ODBC_DBSERVER__" | ||
+ | "Trusted_Connection"="Yes" | ||
</pre> | </pre> |
Revision as of 02:20, 18 October 2010
A WPKG Package to create an ODBC Connection
The Installer Package
<package id="ODBC_CONN_X" name="Create ODBC Connect to DB XYZ on SQL 2008 Server ABC..." revision="1.1" reboot="false" execute="always"> <depends package-id="SETUP" /> <depends package-id="SETUPTOOLS" /> <!-- TxtReplace.exe --> <depends package-id="SQL_SERVER_NATIVECLIENT_10.0" /> <variable name="LOCALDOWNLOADS" value="C:\downloads\provisioning" /> <variable name="WPKGHOME" value="\\enterprise\development\infrastructure\provisioning\wpkg-1.1.2\" /> <variable name="tools" value="c:\tools" /> <variable name="ODBC_DSN_NAME" value="ODBC_CONN_Z" /> <variable name="ODBC_DBSERVER" value="SQLDEV-2005-A" /> <variable name="ODBC_DBNAME" value="AutomationTest" /> <variable name="ODBC_DESC" value="A test of blah for blah" /> <variable name="ODBC_DRIVERNAME" value="SQL Server" /> <variable name="ODBC_TEMPLATE_FILE" value="ODBC_template_SQL2K5_int_auth_no_db.reg" /> <check type="registry" condition="equals" path="HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI\ODBC Data Sources\%ODBC_DSN_NAME%" value="%ODBC_DRIVERNAME%" /> <install cmd="xcopy /Y "%WPKGHOME%\ODBC\%ODBC_TEMPLATE_FILE%" "%LOCALDOWNLOADS%\"" /> <install cmd="%tools%\TxtReplace\TxtReplace.exe -i "%LOCALDOWNLOADS%\%ODBC_TEMPLATE_FILE%" -r __ODBC_DSN_NAME__ "%ODBC_DSN_NAME%" -r __ODBC_DESCRIPTION__ "%ODBC_DESC%" -r __ODBC_DBSERVER__ "%ODBC_DBSERVER%" -r __ODBC_DBNAME__ "%ODBC_DBNAME%" " /> <install cmd="%tools%\reg.exe import "%LOCALDOWNLOADS%\%ODBC_TEMPLATE_FILE%"" /> <remove cmd="cmd /c %tools%\reg.exe DELETE "HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI\ODBC Data Sources" /v "%ODBC_DSN_NAME%" /f" /> <remove cmd="cmd /c %tools%\reg.exe DELETE "HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI\%ODBC_DSN_NAME%" /f" /> </package>
The Registry Template
This requires "TxtReplace.exe" substitution utility, and "reg.exe" from the Windows 2000 resource kit (on the W2K CD)
Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI\ODBC Data Sources] "__ODBC_DSN_NAME__"="SQL Server" [HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI\__ODBC_DSN_NAME__] "Driver"="C:\\WINDOWS\\system32\\SQLSRV32.dll" "Description"="__ODBC_DESCRIPTION__" "Server"="__ODBC_DBSERVER__" "Trusted_Connection"="Yes"