How to can create a ODBC DSN connection from file .bat at Windows? ¿ Is possible ?
Manually create an ODBC connection on your PC using the "Data Sources (ODBC)" applet in Admin tools.
Launch regedit and go to HKLM\Software\ODBC and export the whole lot from ODBC down to a .reg file. This is a right click option on the folder.
Open the exported file in Notepad now you need to delete everything that doesn't refer to your particular ODBC connection.
You should end up with a registry file looking something like this
It may be slightly different depending on connection settings and such like. You will need the two sections, the data sources defines the type of connection, in this instance a SQL server one, then the bit that tells you what it is called, which driver to use and what sort of authentication to use. this will all be done when you set up the connection, you just need the .reg file with it in.
You can then import it on any pc by either double clicking the reg file or if you have the facility run a script to import it using regedit. You can call this import from a batch file: