HTFC Forums

H.T.F.C.

How To Fix Computers





Go Back   HTFC Forums > Software Newsgroups > Windows XP

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1  
Old 04-29-2007, 03:39 AM
John
 
Posts: n/a
Default Creating Data Sources (ODBC) via code

Hi

I need to create a User DSN based on SQL Server driver under Data Sources
(ODBC). As I need to do it on multiple PCs, is there a script or another
automated way to do this quickly?

Thanks

Regards


Reply With Quote
Sponsored Links
Fix your Windows Problems - FAST.
FREE Safe Scan Registry Check. Locate & Fix Errors in Minutes!
  #2  
Old 04-29-2007, 03:48 AM
CreateWindow
 
Posts: n/a
Default Re: Creating Data Sources (ODBC) via code

Hi John,

This looks good:
http://www.microsoft.com/technet/scr...4/hey1110.mspx

For remote PC's you will need to use a UNC path and run the script with an
account that is also valid administrative account on your remote PC's.

CreateWindow
http://justldap.com




"John" <John@nospam.infovis.co.uk> wrote in message
news:Oc0bPegiHHA.680@TK2MSFTNGP06.phx.gbl...
> Hi
>
> I need to create a User DSN based on SQL Server driver under Data Sources
> (ODBC). As I need to do it on multiple PCs, is there a script or another
> automated way to do this quickly?
>
> Thanks
>
> Regards
>
>



Reply With Quote
  #3  
Old 04-29-2007, 04:48 AM
John
 
Posts: n/a
Default Re: Creating Data Sources (ODBC) via code

Hi

Many Thanks. Looks good. Just one thing, how do I add the username and
password for SQL Server authentication?

Thanks again

Regards


Const HKEY_LOCAL_MACHINE = &H80000002

strComputer = "."

Set objReg=GetObject("winmgmts:{impersonationLevel=imp ersonate}!\\" & _
strComputer & "\root\default:StdRegProv")

strKeyPath = "SOFTWARE\ODBC\ODBC.INI\ODBC Data Sources"
strValueName = "My SQL Server"
strValue = "SQL Server"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValu e

strKeyPath = "SOFTWARE\ODBC\ODBC.INI\My SQL Server"

objReg.CreateKey HKEY_LOCAL_MACHINE,strKeyPath

strKeyPath = "SOFTWARE\ODBC\ODBC.INI\My SQL Server"

strValueName = "Database"
strValue = "My Database"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValu e

strValueName = "Driver"
strValue = "C:\WINDOWS\System32\SQLSRV32.dll"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValu e

strValueName = "Server"
strValue = "111.111.111.111"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValu e

strValueName = "Trusted_Connection"
strValue = "No"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValu e



"CreateWindow" <createwindow@gmail.com> wrote in message
news:MbadnZsaYPcSmqnbnZ2dneKdnZydnZ2d@giganews.com ...
> Hi John,
>
> This looks good:
> http://www.microsoft.com/technet/scr...4/hey1110.mspx
>
> For remote PC's you will need to use a UNC path and run the script with an
> account that is also valid administrative account on your remote PC's.
>
> CreateWindow
> http://justldap.com
>
>
>
>
> "John" <John@nospam.infovis.co.uk> wrote in message
> news:Oc0bPegiHHA.680@TK2MSFTNGP06.phx.gbl...
>> Hi
>>
>> I need to create a User DSN based on SQL Server driver under Data Sources
>> (ODBC). As I need to do it on multiple PCs, is there a script or another
>> automated way to do this quickly?
>>
>> Thanks
>>
>> Regards
>>
>>

>
>



Reply With Quote
  #4  
Old 04-29-2007, 05:04 PM
Dave Patrick
 
Posts: n/a
Default Re: Creating Data Sources (ODBC) via code

You can use Reg_Sz string for "LastUser" but you can't store the password in
the registry.

--

Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect

"John" wrote:
> Hi
>
> Many Thanks. Looks good. Just one thing, how do I add the username and
> password for SQL Server authentication?
>
> Thanks again
>
> Regards
>
>
> Const HKEY_LOCAL_MACHINE = &H80000002
>
> strComputer = "."
>
> Set objReg=GetObject("winmgmts:{impersonationLevel=imp ersonate}!\\" & _
> strComputer & "\root\default:StdRegProv")
>
> strKeyPath = "SOFTWARE\ODBC\ODBC.INI\ODBC Data Sources"
> strValueName = "My SQL Server"
> strValue = "SQL Server"
> objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValu e
>
> strKeyPath = "SOFTWARE\ODBC\ODBC.INI\My SQL Server"
>
> objReg.CreateKey HKEY_LOCAL_MACHINE,strKeyPath
>
> strKeyPath = "SOFTWARE\ODBC\ODBC.INI\My SQL Server"
>
> strValueName = "Database"
> strValue = "My Database"
> objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValu e
>
> strValueName = "Driver"
> strValue = "C:\WINDOWS\System32\SQLSRV32.dll"
> objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValu e
>
> strValueName = "Server"
> strValue = "111.111.111.111"
> objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValu e
>
> strValueName = "Trusted_Connection"
> strValue = "No"
> objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValu e
>
>
>
> "CreateWindow" <createwindow@gmail.com> wrote in message
> news:MbadnZsaYPcSmqnbnZ2dneKdnZydnZ2d@giganews.com ...
>> Hi John,
>>
>> This looks good:
>> http://www.microsoft.com/technet/scr...4/hey1110.mspx
>>
>> For remote PC's you will need to use a UNC path and run the script with
>> an account that is also valid administrative account on your remote PC's.
>>
>> CreateWindow
>> http://justldap.com
>>
>>
>>
>>
>> "John" <John@nospam.infovis.co.uk> wrote in message
>> news:Oc0bPegiHHA.680@TK2MSFTNGP06.phx.gbl...
>>> Hi
>>>
>>> I need to create a User DSN based on SQL Server driver under Data
>>> Sources (ODBC). As I need to do it on multiple PCs, is there a script or
>>> another automated way to do this quickly?
>>>
>>> Thanks
>>>
>>> Regards
>>>
>>>

>>
>>

>
>


Reply With Quote
Sponsored Links

Powered by vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0
© 2004 - 2007 Web-S-Sense Pty. Ltd. Usenet and forums posts © their respective authors.
Ad Management by RedTyger