#158578 - 2006-03-0906:22 AMRe: Change text string in multiple INI files
NTDOCNTDOC Administrator
Registered: 2000-07-28
Posts: 11631
Loc: CA
Okay, here is some SILVER PLATTER code for you to run Rich.
Requires KiXtart 4.5 or newer, and does not support NT4. Should work fine on 2000/XP/2003 systems.
Please read the notes within the code on how to use it, and post any questions or comments you have.
Normally one would place the $sComputer parameter first in the UDF, however due to the way that Optional works in KiXtart anything after the word Optional becomes optional so I placed the $sComputer at the end since it is the only optional parameter depending on how you run it. If you run it against a lot of computers then it's not optional really, but if you run it while locally logged on then it's optional and does not need to be supplied.
Shawn, My fault for not being more descriptive. We need to update about 200 clients with the new settings to the INI file. We evealuated dumping a new INI file down to each client but the file contains tons of user specific settings. Some PC's are shared and thus have multiple profiles we need to update. It's a small fraction of the overall number of client's. We figured running it upon login would work fine. If the INI file does not exist, it won't do anything on the clients PC (not real efficient but gets the job done.) Since we know the clients we need to update, NTDOC's solution may actually work better.
Eventually I'd like to look at reading a remote registry in order to perform this and other functions, especially on the shared PC's.
#158580 - 2006-03-0908:31 PMRe: Change text string in multiple INI files
NTDOCNTDOC Administrator
Registered: 2000-07-28
Posts: 11631
Loc: CA
Rich,
The code I posted above will work both locally or remotely. It will still attempt to update all profiles but if the current user does not have Admin rights then the only one it will update is his/her own profile .ini file.
The good part about reading the registry is that it will work correctly regardless of what drive the system was installed on.
Granted that for most if not all systems it would be on the C: drive, but if for some reason it was on E: or F: etc.. then the other method would fail.
Actually DOC, not true. $BaseFolder = ExpandEnvironmentVars(ReadValue($BaseKey+'ProfileList','ProfilesDirectory')) That line will resolve the enviro var an the PC the script is running from, not against. You need to Split() off %SystemDrive% and determine that with separate code. Sorry, I should have mentioned that before.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.
#158582 - 2006-03-0909:33 PMRe: Change text string in multiple INI files
NTDOCNTDOC Administrator
Registered: 2000-07-28
Posts: 11631
Loc: CA
True, but come on. I can pretty much guarantee you that if %SystemDrive% or %SystemRoot% or %windir% or %ProgramFiles% are NOT resolving on your local system then you will be having all types of programs not functioning correctly.
However, that given if Rich is intent on running this locally and wants me to modify per your suggestion I will, but if he has no intention of really running the code then I don't have time to bother with the change.