• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1259
  • Last Modified:

URGENT!!! How do I modify a sql.ini file with a script to add another SQL server to the list?

I must have this file modified within 2 days for all users!.....URGENT!

I need to have our SQL.ini file modified for all users who access our internal application.
Each user has the following ini file:

The file is located on each users' XP machine here:
C:\Documents and Settings\%username%\Application Data\(App Name)

[win32client.dll]
comdll=sqlodb32
[win32client]
clientname=XP(user name here)
[odbcrtr]
remotedbname=(server name here),DSN=(Application here) (server name here)

We need to add another line to the end of the file as listed:
remotedbname=(new server name),DSN=(app name here) (new server name here)





0
stvbrx
Asked:
stvbrx
2 Solutions
 
WmOfTewksCommented:
Any number of scripting languages can do this; VB, VBScript, Kixstart, AutoIt, this list goes on.  The key, of course, is to get this into the group policy so that it runs on everyone's system.  That's where I fall short.

However, I am an AutoIt (http://www.autoitscript.com/autoit3/) afficianado and the script (briefly) would be:
IniWrite("path_to_SQL.ini", "odbcrtr", "remotedbname", "(new server name),DSN=(app name here) (new server name here)" )

AutoIt can be compiled to an EXE for running anywhere.

Good luck.
0
 
Michael PfisterCommented:
Do you have some kind of login script in place? If its a command line script you can add these lines

@echo off
SET SQLINI=%userprofile%\Application Data\(App Name)\SQL.INI
findstr /I (new server name) "%SQLINI%"
If errorlevel 1 goto :AddLine
Goto :EOF
:AddLine
Echo remotedbname=(new server name),DSN=(app name here) (new server name here)>>"%SQLINI%"
Goto :EOF

You probably have to tweak it a bit to fit into your script.
0
 
callrsCommented:
Below is a two-line Quick Macros (www.quickmacros.com) script  I use
 - Sets "MinPagingFileSize=1000000" in [386Enh] section of system.ini:

str f="C:\windows\system.ini"
rset 1 "ConservativeSwapfileUsage" "386Enh" f

-----
 You can simply add a line to the very end of a file too. E.g. in your case:

str myuser myclient myapp f addThis
myuser=getenv("username"); myapp="Some App"; myclient.from("XP" myuser)
f.format("C:\Documents and Settings\%s\Application Data\%s\SQL.ini" myuser myapp)

addThis.format("[]remotedbname=%s, DSN=%s %s" "(new server name)" "(app name)" "(new server name)")
addThis.setfile(f -1);  mes _s.format("%s   added to %s" addThis f)

0
 
stvbrxAuthor Commented:
Thanks for the quick response WmOfTewks and mpfister!

You two were very quick to help and within minutes of each other....so I'll split points.
(This was my first post, so I do hope this is in order here.)

It looks like mpfister is probably the best suited for my situation since it can be applied directly to my logon script.

thanks to all!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now