Rename a section or delete all the keys in INI file
Posted: Tue May 06, 2014 10:06 am
Hi , I have around 20 keys+values under one section in an INI file and trying to remove all the keys or rename the section at least so my server does not read this section any more.
I tried Reading all the ini file content via ReadAll from text and parse the strings and having a loop to edit ini file content using Line-> remove in a loop for that section each line . It reads all the line and I can get each key and value but at the end it just deletes one row and not all.
you can see below what I did:
===========================================================================================================================
Read from Text File #READALL\$TARGETDIR$\Server\SvrCnfg.ini into Variable FieldMapSettings (get EOF into Test)
Parse String $FieldMapSettings$ into Variables and FieldMapSettings1 (Split at first occurrence of pattern)
Parse String $FieldMapSettings1$ into Variables FieldMapSettings2 and (Split at first occurrence of pattern)
Parse String $FieldMapSettings2$ into Variables FieldMapSettingsEach and FieldMapSettingsRest (Split at first occurrence of pattern)
while Variable FieldMapSettingsEach not Equals loop
Parse String $FieldMapSettingsEach$ into Variables FieldMapSettingsKey and FieldMapSettingsValue (Split at first occurrence of pattern)
if Variable FieldMapSettingsKey not Equals
Edit INI File $TARGETDIR$\Server\SvrCnfg.ini, [FieldMap] $FieldMapSettingsKey$=$FieldMapSettingsValue$
end
Parse String $FieldMapSettingsRest$ into Variables FieldMapSettingsEach and FieldMapSettingsRest (Split at first occurrence of pattern)
wend
=================================================================================================================================
Anyone has any idea how to rename the section or remove all the keys?
Thanks
Samira
I tried Reading all the ini file content via ReadAll from text and parse the strings and having a loop to edit ini file content using Line-> remove in a loop for that section each line . It reads all the line and I can get each key and value but at the end it just deletes one row and not all.
you can see below what I did:
===========================================================================================================================
Read from Text File #READALL\$TARGETDIR$\Server\SvrCnfg.ini into Variable FieldMapSettings (get EOF into Test)
Parse String $FieldMapSettings$ into Variables and FieldMapSettings1 (Split at first occurrence of pattern)
Parse String $FieldMapSettings1$ into Variables FieldMapSettings2 and (Split at first occurrence of pattern)
Parse String $FieldMapSettings2$ into Variables FieldMapSettingsEach and FieldMapSettingsRest (Split at first occurrence of pattern)
while Variable FieldMapSettingsEach not Equals loop
Parse String $FieldMapSettingsEach$ into Variables FieldMapSettingsKey and FieldMapSettingsValue (Split at first occurrence of pattern)
if Variable FieldMapSettingsKey not Equals
Edit INI File $TARGETDIR$\Server\SvrCnfg.ini, [FieldMap] $FieldMapSettingsKey$=$FieldMapSettingsValue$
end
Parse String $FieldMapSettingsRest$ into Variables FieldMapSettingsEach and FieldMapSettingsRest (Split at first occurrence of pattern)
wend
=================================================================================================================================
Anyone has any idea how to rename the section or remove all the keys?
Thanks
Samira