mjm1231 Posted March 11, 2005 Posted March 11, 2005 I use a vbscript to add the DSN entries as part of the application install for our database application. You could use the same thing during unattend setup, or use .reg keys to achieve the same thing.WSH SCRIPT FOR CREATING DSN ENTRIES IN FOR ODBC.'ARRAY OF SETTINGS FOR EACH DSN ENTRY.'EACH ELEMENT OF DSNLIST IS AN ARRAY OF SETTINGS FOR THAT DSN.Dim DSNLIST (4) 'CONSTANTS FOR REFERENCING THE DSN SETTINGS FROM THE DSNLIST ARRAYConst DSNname = 0Const DSNdesc = 1Const DSNServer = 2Const DSN_DB = 3'THE REGISTRY KEY FOR THE SYSTEM DSN SETTINGSConst DSNkey = "HKLM\SOFTWARE\ODBC\ODBC.INI"'POPULATE DSNLIST WITH DSN SETTINGS. TO ADD TO LIST, REMEMBER TO CHANGE THE DIM, AND FOR LOOPDSNLIST(0) = Array("DSN name", "description", "Server", "database")DSNLIST(1) = Array("DSN name", "description", "Server", "database")DSNLIST(2) = Array("DSN name", "description", "Server", "database")DSNLIST(3) = Array("DSN name", "description", "Server", "database")'USE WSH TO WRITE DSN SETTINGS TO REGISTRYstrComputer = "."Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")Set WshShell = WScript.CreateObject("WScript.Shell")'The following loop populates the DSN entries into the registryFor db = 0 to 3 WshShell.RegWrite DSNkey &"\" & DSNLIST(db) (DSNname) & "\Database", DSNLIST(db) (DSN_DB), "REG_SZ" WshShell.RegWrite DSNkey &"\" & DSNLIST(db) (DSNname) & "\Description", DSNLIST(db) (DSNdesc), "REG_SZ" 'Next line turns off the ANSI padding WshShell.RegWrite DSNkey &"\" & DSNLIST(db) (DSNname) & "\AnsiNPW", "No", "REG_SZ" WshShell.RegWrite DSNkey &"\" & DSNLIST(db) (DSNname) & "\Driver", "C:\Windows\System32\SQLSRV32.dll", "REG_SZ" WshShell.RegWrite DSNkey &"\" & DSNLIST(db) (DSNname) & "\Server", DSNLIST(db) (DSNServer), "REG_SZ" 'THE FOLLOWING REGISTRY KEY POPULATES THE ENTRY INTO THE ODBC CONTROL PANEL APPLET WshShell.RegWrite DSNkey &"\ODBC Data Sources\" & DSNLIST(db) (DSNName), "SQL Server", "REG_SZ" 'UNCOMMENT WSCRIPT.ECHO TO DISPLAY ENTRIES AS THEY ARE WRITTEN (PROMPTS FOR OK). 'Wscript.Echo db, DSNLIST(db) (DSNname)NextSet WshSHell = NothingJust change the items in the arrays to match what your actual DSN settings are. If you need to add or change other settings, I would suggest making the settings manually and then inspecting the registry.
Dahi Posted March 11, 2005 Posted March 11, 2005 Set up your ODBC entries, then export the registry entries from HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INIAnd to force SQL Server ODBC to use TCP/IP port 1433 export relevant entries from HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer
oioldman Posted March 15, 2005 Posted March 15, 2005 Just curious, but have you tried this Telenut? as i would like to use but am a little wary of doing so.
Telenut Posted March 15, 2005 Author Posted March 15, 2005 Nope, still have to test it. (I don't use it at home, it is just for testing at work. I'm trying to create a good working unattended installation over network before I suggest the idea to the 'boss'. They are verry, old fashioned here :s, It has to be perfect before they even consider looking at it. And zo I do al the testing after working hours too...)edit: Boss went home this noon :-)It works by just exporting the reg key, and then import it again. Have not tried the other script
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now