Deploy ODBC settings

Author
amartensson
Expert Member
  • Total Posts : 117
  • Scores: 0
  • Reward points: 16530
  • Joined: 2006/07/25 07:54:53
  • Status: offline
2008/09/09 10:02:15 (permalink)
0

Deploy ODBC settings

I'm trying to deploy an ODBC setting to our clients. manually I can do it either via a batscript or through a commandline with the command regedit /s regfile.reg. Odd enough when advertising either the batfile or the regfile with the exact same command, the system dsn is not added. The advertisement claims to be succesful as well! Anyone who has an alternative way of deploying ODBC settings? I've tried this way which I thought would work on several computers, but no luck at all. How can there be a difference between doubleclicking a regfile and running it through SCCM?
#1

5 Replies Related Threads

    jsandys
    Expert Member
    • Total Posts : 1438
    • Scores: 131
    • Reward points: 71080
    • Joined: 2005/03/24 01:20:32
    • Location: San Antonio, TX
    • Status: offline
    RE: Deploy ODBC settings 2008/09/09 11:29:00 (permalink)
    5 (1)
    Context.  The only difference between the two is typically the account used to perform the action.  When deploying software or running a program through ConfigMgr/SMS while using the install with admin credentials option, the account used is the local System account.  Most of the time this does not cause any issues, but there are a few implications like the System account does not have its own HKU hive, you cannot run as/switch user contexts, the System account does not have a profile, etc.
     
    Given that creating a System DSN writes to HKLM, my only hunch is that a reboot is required (or a service restarted) to make the change effective.  Have you checked the registry to verify the change was made?  Are your clients Vista or XP?
     
     

    Jason
    Configuration Manager MVP
    My Blog
    Twitter @JasonSandys
    #2
    amartensson
    Expert Member
    • Total Posts : 117
    • Scores: 0
    • Reward points: 16530
    • Joined: 2006/07/25 07:54:53
    • Status: offline
    RE: Deploy ODBC settings 2008/09/10 03:36:08 (permalink)
    0
    The clients I've tried are both XP and Vista, none work. I've checked the registry and the settings are not imported at all, even after a reboot. If the problem is context, would it be possible to create a new .bat or.cmd with the "Runas...." command in it to make it work?
    #3
    eschloss
    Expert Member
    • Total Posts : 612
    • Scores: 27
    • Reward points: 30880
    • Joined: 2004/09/07 09:46:15
    • Location: Cincinnati
    • Status: offline
    RE: Deploy ODBC settings 2008/09/10 07:46:57 (permalink)
    0
    I always use a reg file when I need to deploy ODBC.  Here is an example of one that I use.
     
    Windows Registry Editor Version 5.00
    [HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI]
    [HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI\ODBC_Name]
    "Driver"="C:\\WINNT\\System32\\SQLSRV32.dll"
    "Server"="SERVER\\NAMEDINSTANCE"

    [HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI\ODBC Data Sources]
    "ODBC_Name"="SQL Server"
     
    Apply this reg file with "regedit.exe /s FILENAME.reg" in your package and make sure it is run with admin rights.
    #4
    hcortez463
    Expert Member
    • Total Posts : 1144
    • Scores: 95
    • Reward points: 26830
    • Joined: 2005/04/08 09:00:30
    • Status: offline
    RE: Deploy ODBC settings 2008/09/10 07:54:13 (permalink)
    0
    i usually use a vb scirpt for this.. add all your settings in the VB script so it wont be dependent on the .reg file, but ive done it both ways.  Example bellow
     
    ON ERROR RESUME NEXT
    Const HKEY_LOCAL_MACHINE = &H80000002
    strComputer = "."
     
    Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
        strComputer & "\root\default:StdRegProv")
     
    strKeyPath = "SOFTWARE\ODBC\ODBC.INI\ODBC Data Sources"
    strValueName = "XXXX" 'Name of DSN name
    strValue = "SQL Server"
    objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
     
    strKeyPath = "SOFTWARE\ODBC\ODBC.INI\XXXX" 'Same as Name of DSN
    objReg.CreateKey HKEY_LOCAL_MACHINE,strKeyPath
    strKeyPath = "SOFTWARE\ODBC\ODBC.INI\XXXX" 'Same as Name of DSN
    strValueName = "Database"
    strValue = "YYYY" 'Default database name
    objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
     
    strValueName = "Driver"
    strValue = "C:\WINDOWS\System32\SQLSRV32.dll"
    objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
    strValueName = "Server"
    strValue = "ZZZZ" 'SQL server name
    objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue

    If it Helps, Please rate....
    #5
    amartensson
    Expert Member
    • Total Posts : 117
    • Scores: 0
    • Reward points: 16530
    • Joined: 2006/07/25 07:54:53
    • Status: offline
    RE: Deploy ODBC settings 2008/09/10 09:34:36 (permalink)
    0
    Actually I've tried the vbscript way too, with no luck. Works perfect when running manually, but not when doing it through SCCM. I've found a way to do it though, with a little app called CPAU from www.joeware.net . With this I can pass credentials to import the regfile and it works! Thanks for informing me about the context, that really helped:)
    #6
    Jump to:
    © 2018 APG vNext Commercial Version 5.5