Page 1 of 2 12>
Topic Options
#158557 - 2006-03-08 10:03 PM Change text string in multiple INI files
rich100 Offline
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 Offline
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
#158559 - 2006-03-08 10:59 PM Re: Change text string in multiple INI files
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11631
Loc: CA
You're too fast Shawn. Was going to do similar but read location from the Registry.
Top
#158560 - 2006-03-08 11:01 PM Re: Change text string in multiple INI files
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
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.
Top
#158561 - 2006-03-08 11:20 PM Re: Change text string in multiple INI files
rich100 Offline
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 Offline
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 Offline
Moderator
*****

Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
Shawn, do you realy need a %variable% for 'C:\Documents and Settings'? tehee
_________________________
Wait don't order yet,... get KiXforms Designer .NET 2.0 (Beta)
KiXforms Designer .NET 2.0 (Beta)

Top
#158564 - 2006-03-09 01:07 AM Re: Change text string in multiple INI files
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11631
Loc: CA
Actually yes, as he hard coded it so if Windows was installed on any other drive it would have failed.
There is no default Environment Var with the base folder.

Using a remote registry read and then parsing through the folders would have probably been the best solutions as it could / would work both locally and remotely for an Administrator.
 

Top
#158565 - 2006-03-09 01:07 AM Re: Change text string in multiple INI files
Benny69 Offline
Moderator
*****

Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
suppose you could also do a %HomeDrive%+'\Documents and Settings'
_________________________
Wait don't order yet,... get KiXforms Designer .NET 2.0 (Beta)
KiXforms Designer .NET 2.0 (Beta)

Top
#158566 - 2006-03-09 01:08 AM Re: Change text string in multiple INI files
NTDOC Administrator Offline
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 Offline
Moderator
*****

Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
your just pooping all over my fun,
_________________________
Wait don't order yet,... get KiXforms Designer .NET 2.0 (Beta)
KiXforms Designer .NET 2.0 (Beta)

Top
#158568 - 2006-03-09 01:18 AM Re: Change text string in multiple INI files
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
The way I read it, this is to run as an admin script so I presume against remote PCs so local enviro vars are useless.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#158569 - 2006-03-09 01:21 AM Re: Change text string in multiple INI files
Benny69 Offline
Moderator
*****

Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
ooopps, did i hijack this post, sorry
_________________________
Wait don't order yet,... get KiXforms Designer .NET 2.0 (Beta)
KiXforms Designer .NET 2.0 (Beta)

Top
#158570 - 2006-03-09 01:22 AM Re: Change text string in multiple INI files
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Actually, I don't know why I think this - but I got the impression Rich was going to manually visit each workstation, and run something from an server share or memory stick or something - just an impression ... Rich ?

Doc, which regkey were you thinking of using ?

Top
#158571 - 2006-03-09 01:26 AM Re: Change text string in multiple INI files
Benny69 Offline
Moderator
*****

Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
under 'hkcu\volatile environment' is a appdata you might be able to parse
_________________________
Wait don't order yet,... get KiXforms Designer .NET 2.0 (Beta)
KiXforms Designer .NET 2.0 (Beta)

Top
#158572 - 2006-03-09 01:43 AM Re: Change text string in multiple INI files
Benny69 Offline
Moderator
*****

Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
in a min i sense doc or shawn will have a epiphany
_________________________
Wait don't order yet,... get KiXforms Designer .NET 2.0 (Beta)
KiXforms Designer .NET 2.0 (Beta)

Top
#158573 - 2006-03-09 01:44 AM Re: Change text string in multiple INI files
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11631
Loc: CA
Well not too quick, but I'll try to post some generic code that should work a bit better as an Admin script.
Top
#158574 - 2006-03-09 01:44 AM Re: Change text string in multiple INI files
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Quote:

Actually, I don't know why I think this - but I got the impression Rich was going to manually visit each workstation...



Yuck!

You can pull the ProfilesDirectory from:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#158575 - 2006-03-09 01:47 AM Re: Change text string in multiple INI files
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11631
Loc: CA
Yeah, I'll try to post Silver Platter code soon, but I have some other work to do before I go home.
Top
#158576 - 2006-03-09 01:53 AM Re: Change text string in multiple INI files
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Well... maybe it is a terminal server and all the profiles are on one server.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
Page 1 of 2 12>


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

Who's Online
1 registered (Allen) and 363 anonymous users online.
Newest Members
Sir_Barrington, batdk82, StuTheCoder, M_Moore, BeeEm
17886 Registered Users

Generated in 0.077 seconds in which 0.023 seconds were spent on a total of 13 queries. Zlib compression enabled.

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