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
Rename a section or delete all the keys in INI file
-
- Site Admin
- Posts: 5361
- Joined: Sun Aug 22, 2010 4:28 am
Re: Rename a section or delete all the keys in INI file
Dear Shamira,
Are you sure that in your loop sequence, the "Edit INI" command is effectively executed for each entry you want to modify? Did you try to debug it?
Regards
Are you sure that in your loop sequence, the "Edit INI" command is effectively executed for each entry you want to modify? Did you try to debug it?
Regards
Francesco Toscano
InstallAware Software
White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Publications - http://www.installaware.com/publications-review.htm
InstallAware Help -F1 anywhere in the InstallAware IDE
InstallAware Software
White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Publications - http://www.installaware.com/publications-review.htm
InstallAware Help -F1 anywhere in the InstallAware IDE
Re: Rename a section or delete all the keys in INI file
Yes, I added a message there and I can see it goes through all the lines but it just deleted one of the line at the end !
Re: Rename a section or delete all the keys in INI file
Tried this as well but still the same:
for each Element EachLine in $NEWLINE$ delimited Collection of $FieldMapSettingsRest$ do
MessageBox: , EACH LOOP : $EachLine$
Parse String $EachLine$ into Variables FieldMapSettingsKey and FieldMapSettingsValue (Split at first occurrence of pattern)
if Variable FieldMapSettingsKey not Equals
MessageBox: , KEY: $FieldMapSettingsKey$
Edit INI File $TARGETDIR$\Server\SvrCnfg.ini, [FieldMap] $FieldMapSettingsKey$=$FieldMapSettingsValue$
MessageBox: , VALUE : $FieldMapSettingsValue$ is removed
end
next
for each Element EachLine in $NEWLINE$ delimited Collection of $FieldMapSettingsRest$ do
MessageBox: , EACH LOOP : $EachLine$
Parse String $EachLine$ into Variables FieldMapSettingsKey and FieldMapSettingsValue (Split at first occurrence of pattern)
if Variable FieldMapSettingsKey not Equals
MessageBox: , KEY: $FieldMapSettingsKey$
Edit INI File $TARGETDIR$\Server\SvrCnfg.ini, [FieldMap] $FieldMapSettingsKey$=$FieldMapSettingsValue$
MessageBox: , VALUE : $FieldMapSettingsValue$ is removed
end
next
-
- Site Admin
- Posts: 5361
- Joined: Sun Aug 22, 2010 4:28 am
Re: Rename a section or delete all the keys in INI file
Dear Samira,
could you please post the same code as "InstallAware Clipboard Format" within a "Code tag" along with the ini file?
In this way I can try to debug it.
Regards
could you please post the same code as "InstallAware Clipboard Format" within a "Code tag" along with the ini file?
In this way I can try to debug it.
Regards
Francesco Toscano
InstallAware Software
White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Publications - http://www.installaware.com/publications-review.htm
InstallAware Help -F1 anywhere in the InstallAware IDE
InstallAware Software
White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Publications - http://www.installaware.com/publications-review.htm
InstallAware Help -F1 anywhere in the InstallAware IDE
Re: Rename a section or delete all the keys in INI file
~InstallAware Clipboard Data~
~MessageBox~
~{079496CF-81BC-4DD5-AAFD-7F3B9866E7EA}~
~~
~end of main loop~
~0~
~1~
~~
~Next~
~{B25804B6-2713-4F0E-BB6F-121BA56CBE1D}~
~MessageBox~
~{CB5FE7F0-C096-47C9-9E39-0445178EE6EC}~
~~
~end of nested loop~
~0~
~1~
~~
~Next~
~{6AA562D3-6772-4A00-82EC-F0FE42DAA87F}~
~End~
~{FD95F455-3B50-4BE0-9A52-3FCB1F5CB2C2}~
~MessageBox~
~{7023E687-D430-4EDB-9C6D-86F05FEF1A42}~
~~
~EACH Key : $EachKey$ is removed~
~0~
~1~
~~
~Edit INI File~
~{51AD4ED3-2D98-4E7A-A064-2B27B9D8A250}~
~$TARGETDIR$\Server~
~SvrCnfg.ini~
~2~
~FieldMap~
~$EachKey$~
~~
~If~
~{D5E42BAE-2772-4031-B602-BE717D7B04A1}~
~EachKey~
~1~
~JOB~
~TRUE~
~For Each~
~{7D90E15E-B5FE-4DD2-B623-BF194B1FCCFF}~
~EachKey~
~=~
~$EachLine$~
~For Each~
~{70DF04D4-1816-43A0-B1E7-D506DA9E3014}~
~EachLine~
~$NEWLINE$~
~$FieldMapSettings1$~
~Parse String~
~{DE47E7E8-88C3-414E-9568-C67BD3AC8124}~
~$FieldMapSettings1$~
~$NEWLINE$~
~FieldMapSettings2~
~~
~0~
~FALSE~
~FALSE~
~Parse String~
~{F27DADA9-A301-47CB-AAC0-1372EC0F8031}~
~$FieldMapSettings$~
~[FieldMap]~
~~
~FieldMapSettings1~
~0~
~FALSE~
~TRUE~
~Read from Text File~
~{A23BFA6F-C92B-47A6-84E1-31373BD25E97}~
~#READALL\$TARGETDIR$\Server\SvrCnfg.ini ~
~FieldMapSettings~
~Test~
and in the ini file I have this :
[FieldMap]
RESTASK.MANAGER=JOB.JOB_MANAGER
RESTASK.ID=JOB.JOB_ID
RESTASK.NAME=JOB.JOB_DESCR
RESTASK.PRIORITY=JOB.JOB_BKG_BTY_ID
RESTASK.ANALYSIS=JOB.JOB_CRD_ID
~MessageBox~
~{079496CF-81BC-4DD5-AAFD-7F3B9866E7EA}~
~~
~end of main loop~
~0~
~1~
~~
~Next~
~{B25804B6-2713-4F0E-BB6F-121BA56CBE1D}~
~MessageBox~
~{CB5FE7F0-C096-47C9-9E39-0445178EE6EC}~
~~
~end of nested loop~
~0~
~1~
~~
~Next~
~{6AA562D3-6772-4A00-82EC-F0FE42DAA87F}~
~End~
~{FD95F455-3B50-4BE0-9A52-3FCB1F5CB2C2}~
~MessageBox~
~{7023E687-D430-4EDB-9C6D-86F05FEF1A42}~
~~
~EACH Key : $EachKey$ is removed~
~0~
~1~
~~
~Edit INI File~
~{51AD4ED3-2D98-4E7A-A064-2B27B9D8A250}~
~$TARGETDIR$\Server~
~SvrCnfg.ini~
~2~
~FieldMap~
~$EachKey$~
~~
~If~
~{D5E42BAE-2772-4031-B602-BE717D7B04A1}~
~EachKey~
~1~
~JOB~
~TRUE~
~For Each~
~{7D90E15E-B5FE-4DD2-B623-BF194B1FCCFF}~
~EachKey~
~=~
~$EachLine$~
~For Each~
~{70DF04D4-1816-43A0-B1E7-D506DA9E3014}~
~EachLine~
~$NEWLINE$~
~$FieldMapSettings1$~
~Parse String~
~{DE47E7E8-88C3-414E-9568-C67BD3AC8124}~
~$FieldMapSettings1$~
~$NEWLINE$~
~FieldMapSettings2~
~~
~0~
~FALSE~
~FALSE~
~Parse String~
~{F27DADA9-A301-47CB-AAC0-1372EC0F8031}~
~$FieldMapSettings$~
~[FieldMap]~
~~
~FieldMapSettings1~
~0~
~FALSE~
~TRUE~
~Read from Text File~
~{A23BFA6F-C92B-47A6-84E1-31373BD25E97}~
~#READALL\$TARGETDIR$\Server\SvrCnfg.ini ~
~FieldMapSettings~
~Test~
and in the ini file I have this :
[FieldMap]
RESTASK.MANAGER=JOB.JOB_MANAGER
RESTASK.ID=JOB.JOB_ID
RESTASK.NAME=JOB.JOB_DESCR
RESTASK.PRIORITY=JOB.JOB_BKG_BTY_ID
RESTASK.ANALYSIS=JOB.JOB_CRD_ID
-
- Site Admin
- Posts: 5361
- Joined: Sun Aug 22, 2010 4:28 am
Re: Rename a section or delete all the keys in INI file
Let me check.
Regards
Francesco
Regards
Francesco
Francesco Toscano
InstallAware Software
White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Publications - http://www.installaware.com/publications-review.htm
InstallAware Help -F1 anywhere in the InstallAware IDE
InstallAware Software
White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Publications - http://www.installaware.com/publications-review.htm
InstallAware Help -F1 anywhere in the InstallAware IDE
-
- Site Admin
- Posts: 5361
- Joined: Sun Aug 22, 2010 4:28 am
Re: Rename a section or delete all the keys in INI file
Dear Samira,
Please have a look at the attached project.
The project stores the original INI file under SUPPORTDIR, copies it to C:\Mytest and then executes the ini entries removal.
NOTE!
The "Edit INI FILE" is a Windows Installer command (purple command) and due of this, its execution is deferred to Apply Install Execution.
With my sample I used NATIVE ENGINE to execute the command immediately.
Regards
Please have a look at the attached project.
The project stores the original INI file under SUPPORTDIR, copies it to C:\Mytest and then executes the ini entries removal.
NOTE!
The "Edit INI FILE" is a Windows Installer command (purple command) and due of this, its execution is deferred to Apply Install Execution.
With my sample I used NATIVE ENGINE to execute the command immediately.
Regards
- Attachments
-
- TestIni.rar
- (2.16 MiB) Downloaded 424 times
Francesco Toscano
InstallAware Software
White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Publications - http://www.installaware.com/publications-review.htm
InstallAware Help -F1 anywhere in the InstallAware IDE
InstallAware Software
White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Publications - http://www.installaware.com/publications-review.htm
InstallAware Help -F1 anywhere in the InstallAware IDE
Re: Rename a section or delete all the keys in INI file
Dear FrancescoT
Thanks a lot. It works now
Thanks a lot. It works now

-
- Site Admin
- Posts: 5361
- Joined: Sun Aug 22, 2010 4:28 am
Re: Rename a section or delete all the keys in INI file
Happy you solved!
Regards
Regards
Francesco Toscano
InstallAware Software
White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Publications - http://www.installaware.com/publications-review.htm
InstallAware Help -F1 anywhere in the InstallAware IDE
InstallAware Software
White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Publications - http://www.installaware.com/publications-review.htm
InstallAware Help -F1 anywhere in the InstallAware IDE
Who is online
Users browsing this forum: No registered users and 97 guests