We have just recently asked by a customer to come up with a simple method of quickly update more than 500 machines with multiple ODBC connections. That might be a hell-of-a headache for the IT guys The way we have decided to achieve that, was by running a vbscript (I admit that I forgot it even still exists). So I have found the basic idea in the
Guy! Blog Hey, Scripting
an that
ODBC with
SQL administrative
connection. privileges.
'Server (string) - The full database server name. Might be in Server\Instance format 'Database 'User 'Password (string) (string) (string) the the user The name password database used used to to name login login
'Trusted (boolean) - states that the connection is to be trusted connection. When set to True, both ' 'Usage: 'UpdateOdbc 'or 'UpdateOdbc "Because Connection", "Because Connection", "Because\sql2008", "Because\sql2008", "BecauseDB ", "", "BecauseDB", "sa", "jku!oi", False username and password are disregarded.
User,
Password, SQL
with
administrative
'Server (string) - The full database server name. Might be in Server\Instance format 'Database 'User 'Password (string) (string) (string) the the user The name password database used used to to name login login
'Trusted (boolean) - states that the connection is to be trusted connection. When set to True, both ' username and password are disregarded.
'Usage: 'CreateOdbc 'or 'CreateOdbc "Because Connection", "Because Connection", "Because\sql2008", "Because\sql2008", = "BecauseDB", "", "BecauseDB", "sa", "jku!oi", False
Const HKEY_LOCAL_MACHINE
&H80000002
= "." _
& "\root\default:StdRegProv")
= "SOFTWARE\ODBC\ODBC.INI\ODBC
Data
Sources"
'You '"SQL
may Server
to Client Client"
with 10 client
'"SQL
value registryObject.SetStringValue
= "SQL
Server" HKEY_LOCAL_MACHINE,keyPath,valueName,value
= "SOFTWARE\ODBC\ODBC.INI\" &
Name HKEY_LOCAL_MACHINE,keyPath
= "SOFTWARE\ODBC\ODBC.INI\" &
Name = "Database"
Database HKEY_LOCAL_MACHINE,keyPath,valueName,value
of
Defaults
to SQLSRV32.dll Client
SQL you
Driver may 10 -
Client
valueName value =
= "PWD" Password
registryObject.SetStringValue
HKEY_LOCAL_MACHINE,keyPath,valueName,value
= "username" User
HKEY_LOCAL_MACHINE,keyPath,valueName,value
= "LastUser" User
HKEY_LOCAL_MACHINE,keyPath,valueName,value
sub DeleteOdbc(Name) 'Use 'Please ' 'Parameters: 'Name ' 'Usage: 'DeleteOdbc Const HKEY_LOCAL_MACHINE computer Set registryObject=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & computer keyPath registryObject.DeleteKey "Because = Connection" &H80000002 = "." _ (string) The ODBC DSN Name note to that this delete script must an run with ODBC administrative Connection privileges.
keyPath valueName
= "SOFTWARE\ODBC\ODBC.INI\ODBC =
Data
Sources" Name
HKEY_LOCAL_MACHINE,keyPath,valueName
function OdbcNameExists(Name) Const HKEY_LOCAL_MACHINE computer Set registryObject=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & computer keyPath registryObject.GetStringValue = &H80000002 = "." _
if IsNull(key) then OdbcNameExists else OdbcNameExists end if end function = true = false
Comments