This script utilizes VBScript and the Windows Scripting Host to add a DSN for making ODBC connections to SQL Server. The script can easily be modified to create DSNs for other database systems as well.

For example to change the script to add a DSN for an Oracle connection do the following:

3. Change line 32 to the Oracle ODBC drivers name. This can be found in the ODBC manager on the Drivers tab in the Name column.

DriverName = "Oracle73 Ver 2.5"

4. Replace line 69 with

if WindowsAuthentication = True then
RegObj.RegWrite REG_KEY_PATH &
"\AsyncSupport","Enabled","REG_SZ"
else
RegObj.RegWrite REG_KEY_PATH &
"\AsyncSupport","Disabled","REG_SZ"
end if
'Changing WindowsAuthentication to True or False will now Enable or
Disable Asnychronous Support.

The example above is for Version 73 of the Oracle Client. Version 8 has several other values that can be added. If you're curious about the different values that are added to the registry create a bogus ODBC connection in the ODBC Connection Manager. Open the registry editor and browse to HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI. All the keys below this level are connections created in the ODBC Connection Manager. Look at the values added for the connection you just created. Just mimic the entries via the script.

I've also attached a Visual Basic version (VB_AutoDSN.txt) which was written to add a DSN for a SQL Server connection. There's a function called Chk_for_DSN that takes the DataSourceName paramter. It checks to see if the DSN it exists. If it does, it bypasses the creation code. The VB version makes use of Win 32 API functions for accessing the registry and getting the OS version.

Disclaimer: We hope that the information in these pages is valuable to you. Your use of the information contained in these pages, however, is at your sole risk. All information on these pages is provided "as -is", without any warranty, whether express or implied, of its accuracy, completeness, fitness for a particular purpose, title or non-infringement, and none of the third-party products or information mentioned in the work are authored, recommended, supported or guaranteed by me. I shall not be liable for any damages you may sustain by using this information, whether direct, indirect, special, incidental or consequential, even if it has been advised of the possibility of such damages.

Advertiser Disclosure:
Some of the products that appear on this site are from companies from which QuinStreet receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. QuinStreet does not include all companies or all types of products available in the marketplace.