Solved

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

Posted on 2006-06-27
4
1,110 Views
Last Modified: 2009-12-16
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
Comment
Question by:stvbrx
4 Comments
 
LVL 5

Assisted Solution

by:WmOfTewks
WmOfTewks earned 250 total points
ID: 16992639
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
 
LVL 28

Accepted Solution

by:
Michael Pfister earned 250 total points
ID: 16992671
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
 
LVL 30

Expert Comment

by:callrs
ID: 16994151
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
 

Author Comment

by:stvbrx
ID: 16995334
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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Often we come across situations wherein our batch files would be needing to reboot Windows for a variety of reasons. A few of them would be like: (1) Setup files have been updated whose changes can take effect only after a reboot …
Many people tend to confuse the function of a virus with the one of adware, this misunderstanding of the basic of what each software is and how it operates causes users and organizations to take the wrong security measures that would protect them ag…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now