Archive: How to write Multiple INI String


How to write Multiple INI String
Hello,
I'm having trouble to write multiple INI Strings in a single INI file and in same INI_SECTION, for examp...

WriteINIStr "$INSTDIR\somename.ini" "MySec" "val1" "data1"
WriteINIStr "$INSTDIR\somename.ini" "MySec" "val2" "data2"
....and so on

In this case only the last line actually copied to the INI file. But I need atleast 6 lines to go there.

I allready tried INIFlush filename between lines, but it's not working.

So if you guys know anything about it, please share...
Thanks!


Make sure you check the data and Varialbes your sending
through
Nsis may pick them up as a Function or Ect ?
I would check what changed and the data being sent
That's my best guess.


Sorry I don't understand what you mean,
What I intend to know is how I could insert more than one line in a particular INI file in the same INI section:
For example below is a sample INI file...

[MYSECTION]
val1=C:\Windows\temp\t.bmp
val2=C:\Windows\temp\t2.bmp

and so on...

How to create that sort of INI from NSIS.


Is it a label? If it is you can use "\r\n" to create a new line. Example:

"Test\r\nTest2"

But just for Install Options INI Files.

Read more the Install Options Readme...


The code in the first post should work fine. If it doesn't, attach the entire script so we can take a look and see what's wrong.


Script is attached.

Goto the end of Uninstall Section....

Here is sample of the INI in question:

[Rename]
NUL=C:\WINDOWS\TEMP\nst4245.TMP\modern-header.bmp
NUL=C:\WINDOWS\TEMP\NST4245.TMP

---As you see there is only 2 lines, but it should have 5 lines.

Note: Data would varry on every run...


You can't assign more than one value to a certain entry in an INI section. If that was possible you couldn't have changed entries.

Use Delete /REBOOTOK.


Ahha! Well I got it.

But delete /REBOOTOK won't do here
If I use that it will delete the file imdt. so user cann't see the FINISH page at all.

OHHH! this is getting into my previous post....(BUG $PLUGINS FOLDER)
Well now the only way to solve both problem is,,,,

IS THERE ANY WAY TO REMOVE CERTAIN FILES/DIRS AFTER REBOOT?
NSIS WILL NEVER ATTEPT DELETE THOSE IN CURRENT RUN. BUT ONLY AFTER REBOOT!!?


Lose the caps, no need to shout.

You can lock the file manually so Delete won't be able to delete and will therefore use delete on reboot. To lock a file, simply open it using FileOpen. Don't forget to close it using FileClose after you don't need it locked.


Allright then there is a way!

Okay, one request, as you allready downloaded my script,
so if you please modify the script to avail this functonality and attach it back, I'll be verry verry grateful.

PLEASE!

If that not possible, then , a short sample perhaps...
Don't deny this....

please please....


Too busy.


Hey Come on
Don't do this to me...

Okay, tell you what take your time, I'm in no hurry.
So when you are free please do this small work for me and mail it to me at auddy@gawab.com or dipak@myrealbox.com

Okay! I hope this suits you...


You are not paying anything for this service. It's doesn't work like "this is my script" and "please add 1 and 2 and 3".

We have explained you how you get the things you want.

Now you should read the manual and integrate this in your script.

If you have written the code and still have problems, we will be happy to give you some advice.


Here is a Example that I use for my ini file
at Install time and I can do it at uninstall time

; this writes a new section and creates a cetion under it
WriteINIStr $WINDIR\my.ini Blip "#Cracker" "$INSTDIR\fido\language$\r$\n"

;This takes the same section and writes 6 Difern't Entries in Same section
;By adding the $\r$\n at the End it Writes the LINE ! :)
;without the line your would editing the entrie that was already there in the ini section.

WriteINIStr "$WINDIR\my.ini Blip "#Cracker" "Flipper1$\r$\n"
WriteINIStr "$WINDIR\my.ini Blip "#Cracker" "Flipper2$\r$\n"
WriteINIStr "$WINDIR\my.ini Blip "#Cracker" "Flipper3$\r$\n"
WriteINIStr "$WINDIR\my.ini Blip "#Cracker" "Flipper4$\r$\n"
WriteINIStr "$WINDIR\my.ini Blip "#Cracker" "Flipper5$\r$\n"
WriteINIStr "$WINDIR\my.ini Blip "#Cracker" "Flipper6$\r$\n"

From what I have noticed is without the $\r$\n
it rewrites the same lines but with it will modify the current line being targeted ,or create a new line with the $\r$\n if the line isn't already there if ya know what I mean.

I hope this helps :)


Thank you rainmanp7, I don't yet test your code but i will now.

And to Kichik and Joost, you guys are absolutely right.
I'm verry sorry for my behaviour.

However, acording to Kichik's suggestion I studied the manual again, and tried to write my own version(FileOpen)
,but it's not working again...
The revised script I'll about to attach, But in short this is happenning...

If I use FileOpen with append access the fies removed instantly, same, user cann't see the FinishPage.

If I use FileOpen with read only access user cann't see the FinishPage. Surprisngly after the (Un)InstallPage the WelcomePage(un) pops-up with a close button.

I have no idea what is going on


The revised script...


I have no idea why you are trying to find a workaround for the plug-ins folder bug. It has already been fixed in the latest CVS version. You can get the development snapshot for the fix.

If the compilation is a problem, I'll upload a new binary.

The weird behavior is normal, because your are locking files the finish page needs (if you would really want to delete them on reboot, it should be done after the finish page).


I allready visited NSIS home page to download CVS version.
But I could not manage how to get it.
If you just give me a link or expain how to download and install CVS pack.., that will be great.

Please forgive my foolishness, I am just a verry new user for Internet too.


Under development snapshot:

http://nsis.sourceforge.net/development

As for FileOpen and FileClose, you should open the file just before you delete and close it just after you delete it. You don't want to lock it for other things, just the delete line. For example:

FileOpen $0 C:\bla w
Delete C:\bla
FileClose $0


Thanks to everyone, now it's working.

I'm now using RunOnce(registry), to do the cleanup for me.
Using INI (which I'm trying so far) is also possible with the FileWrite function.

But, for the both cases, I have to switch-back to zLib comp.

When I tried to use LZMA comp.(it's result in smaller file size, you know..), the TEMP-FILES($PLUGINS) do clear, but an another temp file, yes file not folder, with a name like..nsn????.tmp (84kb) appears in the machine's temp folder.

Verry verry strange!Isn't it?


Originally posted by rainmanp7
;This takes the same section and writes 6 Difern't Entries in Same section
;By adding the $\r$\n at the End it Writes the LINE ! :)
;without the line your would editing the entrie that was already there in the ini section.

WriteINIStr "$WINDIR\my.ini Blip "#Cracker" "Flipper1$\r$\n"
WriteINIStr "$WINDIR\my.ini Blip "#Cracker" "Flipper2$\r$\n"
WriteINIStr "$WINDIR\my.ini Blip "#Cracker" "Flipper3$\r$\n"
In the event anyone else finds this thread looking to do something like the above, I figured out another way to do it:

My case is a bit different because the ini file I am editing, UT2004.ini, already has existing "Paths" in the "[Core.System]" section. The problem is that writeINIstr over-writes the first instance of "Paths" repeatly. The fix was to do the following:

  WriteINIStr "$INSTDIR\UT2004.ini" "Core.System" "Paths" "../mymod/*.utx$\r$\nPaths=../mymod/*.uax$\r$\nPaths=../mymod/*.umx$\r$\nPaths=../System/*.u"


In other words, it replaces what happens to be the first "Path=../System/*.u" with a bunch of "Paths=../mymod/<etc>" and appends the "System" path back onto the end.

The great thing is that in the uninstaller, you can just pop the top paths off (like a stack) with multiple:
   DeleteINIStr "$INSTDIR\UT2004.ini" "Core.System" "Paths"


Before the install the section looks like:

[Core.System]
blah here
Paths=../System/*.u
Paths=etc
Paths=etc


After the install the section then looks like:

[Core.System]
blah here
Paths=../mymod/etc
Paths=../mymod/etc
Paths=../System/*.u
Paths=etc
Paths=etc


Of course, before you overwrite the first "Paths" you should read it to make sure you are writing the same value back. Also, to do the uninstall right, it should check if the first "Paths" has not been modified and only then delete them.