Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ODBC DSN entries are HIDDEN but they exist in the Windows Registry

Status
Not open for further replies.

CrimeScene

IS-IT--Management
Jul 5, 2003
59
0
0
In reference to closed thread: thread706-384881

and regarding this similar post:

I have not yet determined how this occurs but when the following value is blank, all of the existing ODBC configurations become COMPLETELY HIDDEN from the user –- whether using the ODBCAD32.EXE tool or when any application prompts the user with a list of pre-configured ODBC connections that truly do exist on their local computer.

1. Open REGEDIT.EXE
2. Navigate to HKLM > SOFTWARE > ODBC > ODBC.INI > ODBC Data Sources
3. In the right pane, the entry “(Default)” has a Data value of blank.

I am able to manually resolve this issue:
1. Simply right-click the “(Default)” entry and choose delete. After confirming deletion, the system will immediately recreate that REG_SZ entry … only this time properly setting its value to “(value not set)”.
2. Refresh the ODBCAD32.EXE window and all of the ODBC configured connections reappear.

This occurs on many of our machines running WinXP SP2.

I would like to be able to automate the correcting (change or delete) of this registry value, using WSH scripting, but I do not know how to manipulate that particular entry. Any suggestions?

Thanks!
 
If you delete the ODBC Data Sources entry from the registry, it will be recreated at the time a child is added to the registry as such:

Option Explicit

Dim WSHShell_hacks
Set WSHShell_hacks = WScript.CreateObject("WScript.Shell")

' =================================================================================================
' MASTER ODBC that, when value is not "(value not set)", will hide all of the ODBC from the viewer.
' By deleting it first, it will be auto-created when the first child is written AND will have the
' proper value of "(value not set)" for this master entry.
' =================================================================================================
WSHShell_hacks.RegDelete "HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI\ODBC Data Sources\"

' =========================================================================
' Establish ODBC configuration as system DSN for SOME_SQL_DB:
' =========================================================================
WSHShell_hacks.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI\ODBC Data Sources\sysdsn_some_sql_db", "SQL Server", "REG_SZ"

WSHShell_hacks.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI\sysdsn_some_sql_db\Database", "some_sql_db", "REG_SZ"

WSHShell_hacks.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI\sysdsn_some_sql_db\Description", "some database", "REG_SZ"

WSHShell_hacks.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI\sysdsn_some_sql_db\Driver", "C:\Windows\system32\SQLSRV32.dll", "REG_SZ"

WSHShell_hacks.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI\sysdsn_some_sql_db\Server", "10.10.5.100\instance_name", "REG_SZ"

WSHShell_hacks.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI\sysdsn_some_sql_db\Trusted_Connection", "Yes", "REG_SZ"

Set WSHShell_hacks = Nothing


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top