#158557 - 2006-03-08 10:03 PM
Change text string in multiple INI files
|
rich100
Lurker
Registered: 2006-03-08
Posts: 3
|
I am trying to modify a text string in multiple INI files (file name is same, directory changes)in subdirectories. I understand how to modify it in one location but need to know how to modify all entries within c:\documents and settings\ username\main.ini . The INI file appears under each user profile. We need to do this in one shot rather than as each user logs in.
Any help would be greatly appreciated.
Thanks, Rich
|
|
Top
|
|
|
|
#158558 - 2006-03-08 10:56 PM
Re: Change text string in multiple INI files
|
Shawn
Administrator
   
Registered: 1999-08-13
Posts: 8611
|
Hi Rich, welcome to KoRG ... hope this helps and makes a good start ... make sure to change the $variables to suite your environment ...
Code:
break on
$path = "c:\documents and settings"
$folder = dir($path)
while @error = 0
$folder = $path + "\" + $folder
if getfileattr($folder) & 16
$profile = $folder + "\" + "main.ini"
if exist($profile)
$= writeprofilestring($profile, "section", "value", 2)
endif
endif
$folder = dir()
loop
exit 1
|
|
Top
|
|
|
|
#158561 - 2006-03-08 11:20 PM
Re: Change text string in multiple INI files
|
rich100
Lurker
Registered: 2006-03-08
Posts: 3
|
Shawn,
Worked like a charm. I wish all technical forums were as productive as this one!
Thanks!
|
|
Top
|
|
|
|
#158562 - 2006-03-09 12:19 AM
Re: Change text string in multiple INI files
|
NTDOC
Administrator
   
Registered: 2000-07-28
Posts: 11631
Loc: CA
|
Quote:
Hey Doc ... while your on the line ... is there not a %variable% for the root of Document and Settings ? I thought there was but cant find.
Not directly but you could do something like this if you didn't want to read the Registry.
Join(Split('%ALLUSERSPROFILE%','\',2),'\')
Though reading the Registry method would allow this to happen from a remote system as well.
|
|
Top
|
|
|
|
#158563 - 2006-03-09 01:04 AM
Re: Change text string in multiple INI files
|
Benny69
Moderator
   
Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
|
Shawn, do you realy need a %variable% for 'C:\Documents and Settings'? tehee
|
|
Top
|
|
|
|
#158565 - 2006-03-09 01:07 AM
Re: Change text string in multiple INI files
|
Benny69
Moderator
   
Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
|
suppose you could also do a %HomeDrive%+'\Documents and Settings'
|
|
Top
|
|
|
|
#158566 - 2006-03-09 01:08 AM
Re: Change text string in multiple INI files
|
NTDOC
Administrator
   
Registered: 2000-07-28
Posts: 11631
Loc: CA
|
Nope, if home drive was not enabled it would fail too
|
|
Top
|
|
|
|
#158567 - 2006-03-09 01:11 AM
Re: Change text string in multiple INI files
|
Benny69
Moderator
   
Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
|
your just pooping all over my fun,
|
|
Top
|
|
|
|
#158569 - 2006-03-09 01:21 AM
Re: Change text string in multiple INI files
|
Benny69
Moderator
   
Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
|
ooopps, did i hijack this post, sorry
|
|
Top
|
|
|
|
#158571 - 2006-03-09 01:26 AM
Re: Change text string in multiple INI files
|
Benny69
Moderator
   
Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
|
under 'hkcu\volatile environment' is a appdata you might be able to parse
|
|
Top
|
|
|
|
#158572 - 2006-03-09 01:43 AM
Re: Change text string in multiple INI files
|
Benny69
Moderator
   
Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
|
in a min i sense doc or shawn will have a epiphany
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 507 anonymous users online.
|
|
|