PC Review


Reply
Thread Tools Rate Thread

Creating Data Sources (ODBC) via code

 
 
John
Guest
Posts: n/a
 
      29th Apr 2007
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
 
 
 
 
CreateWindow
Guest
Posts: n/a
 
      29th Apr 2007
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
 
John
Guest
Posts: n/a
 
      29th Apr 2007
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=impersonate}!\\" & _
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,strValue

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,strValue

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

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

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



"CreateWindow" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> 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
 
Dave Patrick
Guest
Posts: n/a
 
      29th Apr 2007
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=impersonate}!\\" & _
> 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,strValue
>
> 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,strValue
>
> strValueName = "Driver"
> strValue = "C:\WINDOWS\System32\SQLSRV32.dll"
> objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
>
> strValueName = "Server"
> strValue = "111.111.111.111"
> objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
>
> strValueName = "Trusted_Connection"
> strValue = "No"
> objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
>
>
>
> "CreateWindow" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> 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" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>> 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
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating Data Sources (ODBC) via code John Windows XP New Users 3 29th Apr 2007 05:04 PM
Creating Data Sources (ODBC) via code John Windows XP Security 3 29th Apr 2007 05:04 PM
ODBC Data Sources Landley Microsoft Dot NET 5 28th Jun 2005 06:03 PM
ODBC data sources Peter M Windows XP Security 1 7th Dec 2003 03:38 PM
ODBC Data Sources JBentley Microsoft Windows 2000 Setup 1 18th Nov 2003 04:01 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:37 PM.