Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Script to create ODBC connection

I need to deploy some software through SMS/SCCM and the software requires that an ODBC connection be created in Windows. The connection information I was given requires a user name and password. I have a batch script to import the connection information into the registry, however I don't know how to go about putting the user name and password in. I'd like to script this or put it in some kind of distributable package.

Thanks, -Mathew

like image 800
Mathew Avatar asked Dec 10 '09 18:12

Mathew


3 Answers

You may use the follow script:

%WINDIR%\System32\odbcconf.exe CONFIGDSN "SQL Server" "DSN=ControltubProducao|Description=ControltubProducao|SERVER=10.23.22.18|Trusted_Connection=No|Database=Controltub"
%WINDIR%\SysWOW64\odbcconf.exe CONFIGDSN "SQL Server" "DSN=ControltubProducao|Description=ControltubProducao|SERVER=10.23.22.18|Trusted_Connection=No|Database=Controltub"

enter image description here

like image 99
Izaac Silva Avatar answered Nov 05 '22 20:11

Izaac Silva


Here are examples of how to directly edit the ODBC Registry settings with VBScript, PowerShell, or Perl.

like image 45
ewall Avatar answered Nov 05 '22 20:11

ewall


Here's the script I use (jan. 2015). Replace all <> with your names:

@echo off
cls

echo Configure user Data Sources for <ApplicationName>
echo.

set dsn_name=<OdbcLinkName>
set config_dsn=configdsn "SQL Server" "DSN=%dsn_name%|Server=<SqlServerName>|Database=<DatabaseName>|Trusted_Connection=yes"

%windir%\system32\odbcconf %config_dsn%
%windir%\syswow64\odbcconf %config_dsn%

echo Data Source "%dsn_name%" has been configured.
echo.
echo Done.
echo.
pause
like image 5
Sylvain Rodrigue Avatar answered Nov 05 '22 21:11

Sylvain Rodrigue