Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Environment variable in ini files?

Status
Not open for further replies.

gbl

MIS
Joined
Sep 6, 2001
Messages
262
Location
CA
We have a group of 20 - 30 ini files used in a program on our network to manage configurations within that program.
They all contain a line such as
variable=<path>\filename.ext
where <path> = t:\x\y or t:\x\z and x,y, z are subfolders in the path
and t is a mapping to a network drive
I need to create a copy of these ini files where the <path> is changed to c:\w\y or c:\w\z, where x, y,w are subfolders and y and z are the same in both examples of <path>, c: is a local drive

Can I create environment variables that could be defined at the top of each ini so that only these top lines have to be changed in each ini file?

Thanks for any help
 
I may be misunderstanding the issue, but:

. if you change the MAP for T, then you should be done, assuming the folder structure is the same;

. if the assignment is really variable=%path%\filename.ext, then changing %path% earlier in the script should be sufficient.

 
Thanks for your reply BCastner.
I am rusty on scripting and variables but this is the idea. Blocks on the ini files appear like this:

[Templates\Letter]
PrintCondition=T1Info.B[8]=0
UserFile=T:\GreenPoint\Profile\Templates\2003 T1 TP1 letter.RTF
UserFileUseEmbedded=0

They are numerous throughout the 30 ini files, and can change at least annually, and the maker of the software does updates a few times during the year as well, that can also change the content of the ini file. The goal I have is to have a variable that allows me to achieve the equivalent of:

[Templates\Letter]
PrintCondition=T1Info.B[8]=0
UserFile=C:\Program Files\Profile\Templates\2003 T1 TP1 letter.RTF
UserFileUseEmbedded=0

in places where the original reference to something = t:\....
appears. I want to generate as easily as possible the second set of ini files that point to C instead of T, each time there is a change by the software manufacturer that leads to a change in the first set of ini files.
Hopefully this explains it better.
 
What you need is something close to the Unix Grep command to find and replace all instances of these files.

One possible source of relief is that MS has released as part of the resouce kit for Windows 2003 a very good Grep equivalent.

Use Grep.exe to filter, substitute and replace the files:

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top