Page 2 of 2 <12
Topic Options
#190448 - 2008-10-31 05:25 PM Re: Calling a .bat/.exe during logon [Re: markdavies1978]
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
Try adding this to your KiX script and test it.

 Code:
$WinIni = %windir%+"\win.ini"
$ODBCIni = %windir%+"\odbc.ini"
$RC = WriteProfileString($WinIni,"db9server","Driver","C:\WINNT\SYSTEM\sqlsrvr.dll")
$RC = WriteProfileString($WinIni,"db9server","Description","")
$RC = WriteProfileString($WinIni,"db9server","Server","db9server")
$RC = WriteProfileString($WinIni,"db9server","Address","172.27.44.54,1443")
$RC = WriteProfileString($WinIni,"db9server","UseProcForPrepare","Yes")
$RC = WriteProfileString($WinIni,"db9server","QuotedId","Yes")
$RC = WriteProfileString($WinIni,"db9server","AnsiNPW","Yes")
$RC = WriteProfileString($WinIni,"db9server","OemtoAnsi","No")
$RC = WriteProfileString($WinIni,"db9server","Trusted_Connection","")

$RC = WriteProfileString($ODBCIni,"ODBC Data Sources","db9server","SQL Server")
_________________________
Today is the tomorrow you worried about yesterday.

Top
#190450 - 2008-10-31 06:11 PM Re: Calling a .bat/.exe during logon [Re: BradV]
markdavies1978 Offline
Fresh Scripter

Registered: 2008-10-30
Posts: 17
 Originally Posted By: BradV
What is the content of test.bat?


cscript odbc_ini.vbs

Top
#190451 - 2008-10-31 06:12 PM Re: Calling a .bat/.exe during logon [Re: Gargoyle]
markdavies1978 Offline
Fresh Scripter

Registered: 2008-10-30
Posts: 17
 Originally Posted By: Gargoyle
Try adding this to your KiX script and test it.

 Code:
$WinIni = %windir%+"\win.ini"
$ODBCIni = %windir%+"\odbc.ini"
$RC = WriteProfileString($WinIni,"db9server","Driver","C:\WINNT\SYSTEM\sqlsrvr.dll")
$RC = WriteProfileString($WinIni,"db9server","Description","")
$RC = WriteProfileString($WinIni,"db9server","Server","db9server")
$RC = WriteProfileString($WinIni,"db9server","Address","172.27.44.54,1443")
$RC = WriteProfileString($WinIni,"db9server","UseProcForPrepare","Yes")
$RC = WriteProfileString($WinIni,"db9server","QuotedId","Yes")
$RC = WriteProfileString($WinIni,"db9server","AnsiNPW","Yes")
$RC = WriteProfileString($WinIni,"db9server","OemtoAnsi","No")
$RC = WriteProfileString($WinIni,"db9server","Trusted_Connection","")

$RC = WriteProfileString($ODBCIni,"ODBC Data Sources","db9server","SQL Server")


How can I run this for specific users only?


Edited by markdavies1978 (2008-10-31 06:12 PM)

Top
#190452 - 2008-10-31 06:46 PM Re: Calling a .bat/.exe during logon [Re: markdavies1978]
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
In this part of your script
 Code:
IF INGROUP ("ODBC_UPDATE")
RUN "L:\Policy_Area\TEST.bat"

ENDIF


Replace your run statement with the above code
_________________________
Today is the tomorrow you worried about yesterday.

Top
#190453 - 2008-10-31 07:34 PM Re: Calling a .bat/.exe during logon [Re: Gargoyle]
markdavies1978 Offline
Fresh Scripter

Registered: 2008-10-30
Posts: 17
Thanks Gargoyle, getting there!

It has now addedd the required ODBC entry apart from the IP address!

Top
#190454 - 2008-10-31 07:55 PM Re: Calling a .bat/.exe during logon [Re: markdavies1978]
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
Glad to help. There are ways to make the code cleaner and faster if you ever want to explore those options, but that is your call. And welcome to the world of KiX.
_________________________
Today is the tomorrow you worried about yesterday.

Top
#190460 - 2008-11-01 12:11 PM Re: Calling a .bat/.exe during logon [Re: Gargoyle]
markdavies1978 Offline
Fresh Scripter

Registered: 2008-10-30
Posts: 17
I'm still stuggling to get the IP address added to the ODBC setting.

It adds the SQL entry & server name fine which is great just not the Network Address...

I think the code from the previous posts isn't adding the address to C:\Windows\win.ini & C:\Windows\ODBC.ini

Top
#190463 - 2008-11-01 05:06 PM Re: Calling a .bat/.exe during logon [Re: markdavies1978]
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
This is the line that is not working ?

$RC = WriteProfileString($WinIni,"db9server","Address","172.27.44.54,1443")

Add this line directly after it and see what the error code is

 Code:
"Return code was "+@Error+" "+@SError ?
_________________________
Today is the tomorrow you worried about yesterday.

Top
#190475 - 2008-11-03 08:28 PM Re: Calling a .bat/.exe during logon [Re: Gargoyle]
markdavies1978 Offline
Fresh Scripter

Registered: 2008-10-30
Posts: 17
Gargoyle,

Having had a chat with 1 of my developers I simply had to adjust the example code you posted.

Thanks.

Top
#190478 - 2008-11-03 10:53 PM Re: Calling a .bat/.exe during logon [Re: markdavies1978]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22343
Loc: OK
why use the .bat file, when you can just shell the same line with kix?

if you still want to keep on using that vbs-script, that is...
_________________________
!

download KiXnet

Top
Page 2 of 2 <12


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 145 anonymous users online.
Newest Members
Jodey, Hiker, GTRoberts, KatieQuinn, Brennnnn
17684 Registered Users

Generated in 0.036 seconds in which 0.013 seconds were spent on a total of 14 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org