Sign in to follow this  
Followers 0
MaCgyver

Create Script To Make Configure An Odbc Entry. Can This Be Done?

3 posts in this topic

I did a search and found some threads with ODBC, but nothing very clear as to creating an entry. I want to associate this script with the users log on profile. Can someone post up an example, so I know where to look in the help section.

Thanks in advance.

Share this post


Link to post
Share on other sites



I just spoke to a co-worker at another site and he uses auto it also. He uses v2 and this is what he created.

I guess I can convert that to v3 and edit it for my needs.

SplashTextOn, 400, 200, ODBC Registry Updates, ODBC Change from 00ntsdep to SV000SDEP

RegRead, ENT, REG_SZ, HKEY_LOCAL_MACHINE, SOFTWARE\\ODBC\\ODBC.INI\\ENT, Server

IfEqual, ERRORLEVEL, 0, Gosub, WRENT

RegRead, GL, REG_SZ, HKEY_LOCAL_MACHINE, SOFTWARE\\ODBC\\ODBC.INI\\GL, Server

IfEqual, ERRORLEVEL, 0, Gosub, WRGL

RegRead, SD, REG_SZ, HKEY_LOCAL_MACHINE, SOFTWARE\\ODBC\\ODBC.INI\\SD, Server

IfEqual, ERRORLEVEL, 0, Gosub, WRSD

RegRead, TCP, REG_SZ, HKEY_LOCAL_MACHINE, SOFTWARE\\Microsoft\\MSSQLServer\\Client\\ConnectTo, SV000SDEP

IfEqual, ERRORLEVEL, 0, Gosub, TCPIP

IfEqual, ERRORLEVEL, 1, Gosub, TCPIP2

IniRead, SDSServer, C:\\IPS\\Safe Deposit Box Accounting\\sds.ini, DataSource, SD

IfEqual, ERRORLEVEL, 0, Gosub, SDSW

Exit

WRENT:

IfNotEqual, ENT, SV000SDEP, RegWrite, REG_SZ, HKEY_LOCAL_MACHINE, SOFTWARE\\ODBC\\ODBC.INI\\ENT, Server, SV000SDEP

Return

WRGL:

IfNotEqual, GL, SV000SDEP, RegWrite, REG_SZ, HKEY_LOCAL_MACHINE, SOFTWARE\\ODBC\\ODBC.INI\\GL, Server, SV000SDEP

Return

WRSD:

IfNotEqual, SD, SV000SDEP, RegWrite, REG_SZ, HKEY_LOCAL_MACHINE, SOFTWARE\\ODBC\\ODBC.INI\\SD, Server, SV000SDEP

Return

TCPIP:

IfNotEqual, TCP, DBMSSOCN\,SV000SDEP\,1433, RegWrite, REG_SZ, HKEY_LOCAL_MACHINE, SOFTWARE\\Microsoft\\MSSQLServer\\Client\\TDS, SV000SDEP, 7.0

IfNotEqual, TCP, DBMSSOCN\,SV000SDEP\,1433, RegWrite, REG_SZ, HKEY_LOCAL_MACHINE, SOFTWARE\\Microsoft\\MSSQLServer\\Client\\ConnectTo, SV000SDEP, DBMSSOCN\,SV000SDEP\,1433

Return

TCPIP2:

RegWrite, REG_SZ, HKEY_LOCAL_MACHINE, SOFTWARE\\Microsoft\\MSSQLServer\\Client\\ConnectTo, SV000SDEP, DBMSSOCN\,SV000SDEP\,1433

RegWrite, REG_SZ, HKEY_LOCAL_MACHINE, SOFTWARE\\Microsoft\\MSSQLServer\\Client\\TDS, SV000SDEP, 7.0

Return

SDSW:

IfNotInString, SDSServer, SV000SDEP, IniWrite, SERVER=SV000SDEP;Provider=SQL Server, C:\\IPS\\Safe Deposit Box Accounting\\sds.ini, Update, ENT

IfNotInString, SDSServer, SV000SDEP, IniWrite, SERVER=SV000SDEP;Provider=SQL Server, C:\\IPS\\Safe Deposit Box Accounting\\sds.ini, Update, GL

IfNotInString, SDSServer, SV000SDEP, IniWrite, SERVER=SV000SDEP;Provider=SQL Server, C:\\IPS\\Safe Deposit Box Accounting\\sds.ini, DataSource, SD

Return

[ADLIB]

Share this post


Link to post
Share on other sites

if you use the AutoIT V2 to V3 converter you get this.

Maybe you can modify it if it isn't quite right.

;   V2.64 to V3.0.100 (Version 1.0.6)
;   Converted with AutoItV2toV3 [Version 1.0.6]
;   (C) Copyright 2004 J-Paul Mesnage.

; Prologue  ; should be renamed (?) and called somewhere if you are converting  an include file
__init()
; End Prologue

SplashTextOn ( 'ODBC Registry Updates', 'ODBC Change from 00ntsdep to SV000SDEP', 400, 200 )

$ENT = RegRead ( 'HKEY_LOCAL_MACHINE\' & 'SOFTWARE\ODBC\ODBC.INI\ENT', 'Server' )
$__err = Abs(@error); for ERRORLEVEL compatibility checking
if __cmp($__err, 0) then
    WRENT ( )
endif

$GL = RegRead ( 'HKEY_LOCAL_MACHINE\' & 'SOFTWARE\ODBC\ODBC.INI\GL', 'Server' )
$__err = Abs(@error); for ERRORLEVEL compatibility checking
if __cmp($__err, 0) then
    WRGL ( )
endif

$SD = RegRead ( 'HKEY_LOCAL_MACHINE\' & 'SOFTWARE\ODBC\ODBC.INI\SD', 'Server' )
$__err = Abs(@error); for ERRORLEVEL compatibility checking
if __cmp($__err, 0) then
    WRSD ( )
endif

$TCP = RegRead ( 'HKEY_LOCAL_MACHINE\' & 'SOFTWARE\Microsoft\MSSQLServer\Client\ConnectTo', 'SV000SDEP' )
$__err = Abs(@error); for ERRORLEVEL compatibility checking
if __cmp($__err, 0) then
    TCPIP ( )
endif
if __cmp($__err, 1) then
    TCPIP2 ( )
endif

$SDSServer = IniRead ( 'C:\IPS\Safe Deposit Box Accounting\sds.ini', 'DataSource', 'SD', "ERROR" )
if __cmp($__err, 0) then
    SDSW ( )
endif

Exit 

Func WRENT ( )
    if NOT __cmp($ENT, 'SV000SDEP') then
        RegWrite ( 'HKEY_LOCAL_MACHINE\' & 'SOFTWARE\ODBC\ODBC.INI\ENT', 'Server', 'REG_SZ', 'SV000SDEP' )
    endif
    Return 
EndFunc ; WRENT


Func WRGL ( )
    if NOT __cmp($GL, 'SV000SDEP') then
        RegWrite ( 'HKEY_LOCAL_MACHINE\' & 'SOFTWARE\ODBC\ODBC.INI\GL', 'Server', 'REG_SZ', 'SV000SDEP' )
    endif
    Return 
EndFunc ; WRGL


Func WRSD ( )
    if NOT __cmp($SD, 'SV000SDEP') then
        RegWrite ( 'HKEY_LOCAL_MACHINE\' & 'SOFTWARE\ODBC\ODBC.INI\SD', 'Server', 'REG_SZ', 'SV000SDEP' )
    endif
    Return 
EndFunc ; WRSD


Func TCPIP ( )
    if NOT __cmp($TCP, 'DBMSSOCN,SV000SDEP,1433') then
        RegWrite ( 'HKEY_LOCAL_MACHINE\' & 'SOFTWARE\Microsoft\MSSQLServer\Client\TDS', 'SV000SDEP', 'REG_SZ', '7.0' )
    endif
    if NOT __cmp($TCP, 'DBMSSOCN,SV000SDEP,1433') then
        RegWrite ( 'HKEY_LOCAL_MACHINE\' & 'SOFTWARE\Microsoft\MSSQLServer\Client\ConnectTo', 'SV000SDEP', 'REG_SZ', 'DBMSSOCN,SV000SDEP,1433' )
    endif
    Return 
EndFunc ; TCPIP


Func TCPIP2 ( )
    RegWrite ( 'HKEY_LOCAL_MACHINE\' & 'SOFTWARE\Microsoft\MSSQLServer\Client\ConnectTo', 'SV000SDEP', 'REG_SZ', 'DBMSSOCN,SV000SDEP,1433' )
    RegWrite ( 'HKEY_LOCAL_MACHINE\' & 'SOFTWARE\Microsoft\MSSQLServer\Client\TDS', 'SV000SDEP', 'REG_SZ', '7.0' )
    Return 
EndFunc ; TCPIP2


Func SDSW ( )
    if StringInStr ( $SDSServer, 'SV000SDEP', $__strcase ) = 0 then
        IniWrite ( 'C:\IPS\Safe Deposit Box Accounting\sds.ini', 'Update', 'ENT', 'SERVER=SV000SDEP;Provider=SQL Server' )
    endif
    if StringInStr ( $SDSServer, 'SV000SDEP', $__strcase ) = 0 then
        IniWrite ( 'C:\IPS\Safe Deposit Box Accounting\sds.ini', 'Update', 'GL', 'SERVER=SV000SDEP;Provider=SQL Server' )
    endif
    if StringInStr ( $SDSServer, 'SV000SDEP', $__strcase ) = 0 then
        IniWrite ( 'C:\IPS\Safe Deposit Box Accounting\sds.ini', 'DataSource', 'SD', 'SERVER=SV000SDEP;Provider=SQL Server' )
    endif
    Return 
EndFunc ; SDSW



Func myAdLibV2 ( )
if WinExists (  ) then

; Epilogue  Extra Functions needed for Compatibility execution
;           take care of possible redefinition if you are converting  an include file
;
func __cmp ($_1, $_2); to handle Case sensitive comparison
global $__strcase
if $__strcase = 0 then
    return ($_1 = $_2)
else
    return ($_1 == $_2)
endif
endfunc
;
func __init ()  ; to define global variables needed
endfunc
; End Epilogue

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0