Scripting DSN creation?

D

Drew

I have an app that needs to be installed on a few machines (<25) and would
like to know if anyone has written a script for creating DSN's. I need 5
DSN's created for each computer, so this would help out considerably. The
app uses an Access DB. Can anyone give me any advice?

Thanks,
Drew
 
B

Brian

Drew said:
I have an app that needs to be installed on a few machines (<25) and would
like to know if anyone has written a script for creating DSN's. I need 5
DSN's created for each computer, so this would help out considerably. The
app uses an Access DB. Can anyone give me any advice?

Thanks,
Drew

Look up RegisterDatabase in Help, there's an example.
 
A

Andi Mayer

I have an app that needs to be installed on a few machines (<25) and would
like to know if anyone has written a script for creating DSN's. I need 5
DSN's created for each computer, so this would help out considerably. The
app uses an Access DB. Can anyone give me any advice?

Thanks,
Drew

Why not work with DSN-Less connections?
 
B

Bruce Hensley

Drew,

If the DSN is to connect to a SQL server database, there is an example at
The access Web (http://www.mvps.org/access/tables/tbl0014.htm).

If you are creating DSNs for Oracle, I use the following.

Good luck,
Bruce

------------------------------------
Function fnCreateDSN(sDSN, sServerName, sDatabase, sUserID, sPassword)
'Creates a user DSN to an Oracle database, replacing any existing DSN by
that name

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

'This creates a user DSN, perhaps HKLM would create system DSN
Const cRegKey1 = "HKCU\Software\ODBC\ODBC.INI\"
Const cRegKey2 = "HKCU\Software\ODBC\ODBC.INI\ODBC Data Sources\"
Const cRegKey3 = "HKLM\Software\ODBC\ODBCINST.INI\Oracle ODBC Driver\"

Dim sRegKey1
sRegKey1 = cRegKey1 & sDSN & "\"

'Delete the old key if there is one
On Error Resume Next
WshShell.RegDelete sRegKey1

'Find the ODBC driver location from the registry setting
Dim strDriverLoc
strDriverLoc = WshShell.RegRead(cRegKey3 & "Driver")
If strDriverLoc <> "" Then
WshShell.RegWrite sRegKey1 & "Driver", strDriverLoc
Else
MsgBox ("Oracle ODBC Driver not found in registry")
End If

WshShell.RegWrite sRegKey1 & "ServerName", sServerName
WshShell.RegWrite sRegKey1 & "Database", sDatabase
WshShell.RegWrite sRegKey1 & "UserID", sUserID
WshShell.RegWrite sRegKey1 & "Password", sPassword
'WshShell.RegWrite sRegKey1 & "LOBS", "T"
'WshShell.RegWrite sRegKey1 & "FailOver", "T"
'WshShell.RegWrite sRegKey1 & "ResultSets", "T"

'Make the DSN available to the ODBC manager
WshShell.RegWrite cRegKey2 & sDSN, "Oracle ODBC Driver"

Set WshShell = Nothing
End Function
 
D

Drew

Because the software is one that was bought, after looking into it, I found
that it uses Access DB's... Now we are trying to share the app's data for a
few users (yes it is legal and yes the license says so).

Drew
 
D

Drew

I fooled around with this for a while and found some sites around and about.
I have a script that adds the key to the registry, and it looks like this,

- HKLM\Software\ODBC\ODBC.ini\
DSNName1
DSNName2
DSNName3
ODBC Data Sources
ODBC File DSN

When I look at the computer that has the app installed, the registry looks
like this,

- HKLM\Software\ODBC\ODBC.ini\
- DSNName1
- Engines
- Jet
- DSNName2
- Engines
- Jet
- DSNName3
- Engines
- Jet
- ODBC Data Sources
- ODBC File DSN

Do I have to add the Engines > Jet keys under the DSN?

Thanks,
Drew Laing
 
A

Andi Mayer

Because the software is one that was bought, after looking into it, I found
that it uses Access DB's... Now we are trying to share the app's data for a
few users (yes it is legal and yes the license says so).
This is an argument.

why not export the ODBC reg (on one machine) and import this reg file
into the others?
 
D

Drew

That should do it... don't know why I didn't think of this before! Thanks
for helping out!

Drew
 
A

Andi Mayer

That should do it... don't know why I didn't think of this before! Thanks
for helping out!

as usual: why use the easy way, when there is another?

don't worry , we all do it (last week a wrote a 100 lines function,
and on the next day I substuted it with a one-liner )
 
Top