myITforum and Windows IT Pro Forums

 Deploy ODBC settings

Author Message
amartensson

  • Total Posts : 117
  • Scores: 0
  • Reward points : 16530
  • Joined: 7/25/2006
  • Status: offline
Deploy ODBC settings Tuesday, September 09, 2008 10:02 AM (permalink)
0
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
    jsandys

    • Total Posts : 1428
    • Scores: 131
    • Reward points : 68480
    • Joined: 3/24/2005
    • Location: San Antonio, TX
    • Status: offline
    RE: Deploy ODBC settings Tuesday, September 09, 2008 11:29 AM (permalink)
    5
    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

      • Total Posts : 117
      • Scores: 0
      • Reward points : 16530
      • Joined: 7/25/2006
      • Status: offline
      RE: Deploy ODBC settings Wednesday, September 10, 2008 3:36 AM (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

        • Total Posts : 605
        • Scores: 27
        • Reward points : 21190
        • Joined: 9/7/2004
        • Location: Cincinnati
        • Status: offline
        RE: Deploy ODBC settings Wednesday, September 10, 2008 7:46 AM (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

          • Total Posts : 1144
          • Scores: 95
          • Reward points : 26830
          • Joined: 4/8/2005
          • Status: offline
          RE: Deploy ODBC settings Wednesday, September 10, 2008 7:54 AM (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

            • Total Posts : 117
            • Scores: 0
            • Reward points : 16530
            • Joined: 7/25/2006
            • Status: offline
            RE: Deploy ODBC settings Wednesday, September 10, 2008 9:34 AM (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
              Online Bookmarks Sharing: Share/Bookmark

              Jump to:

              Current active users

              There are 0 members and 1 guests.

              Icon Legend and Permission

              • New Messages
              • No New Messages
              • Hot Topic w/ New Messages
              • Hot Topic w/o New Messages
              • Locked w/ New Messages
              • Locked w/o New Messages
              • Read Message
              • Post New Thread
              • Reply to message
              • Post New Poll
              • Submit Vote
              • Post reward post
              • Delete my own posts
              • Delete my own threads
              • Rate post

              2000-2014 ASPPlayground.NET Forum Version 3.9