Wednesday, August 25, 2010

Adding ODBC System DSN's via Group Policy

I needed to push out some new / updated system DSN's today for some reporting changes that are happening next week. Since there's no built in way to do this via group policy, I wound up setting up a "model" computer with all the DSN's I'd need, and then exporting that section of the registry to a .reg file (odbc.reg)

I exported the following section of the registry: HKLM\Software\ODBC\ODBC.INI

The contents of this export looked something like this:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI]

[HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI\DSN1 NAME]
"Driver"="C:\\WINDOWS\\system32\\SQLSRV32.dll"
"Description"="DESCRIPTION"
"Database"="DATABASE"
"LastUser"="USER"
"Trusted_Connection"="Yes"
"Server"="SERVER"

[HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI\DSN 2 NAME]
"Driver"="c:\\WINDOWS\\system32\\sqlncli10.dll"
"Server"="SERVER"
"Database"="DATABASE"
"LastUser"="USER"
"Trusted_Connection"="Yes"

I then went into my Group Policy editor, found the place to specify a login bat file, and added this line to apply the registry setting upon user login:
regedit /s \\SERVER\SHARE\odbc.reg

That's it! Now when my users log in they get DSN's set up just like I want them.

Blog Archive

Hits and Stats


Stats