Skip to content
⌘ NSIS Forum Archive

FileSeek in .ini file

5 posts

ascTim#

FileSeek in .ini file

Hi there,

I can't find what I need in the documentation, I'm probably just blind, but you'll know the answers better I bet. 😉

I want to open an .ini file, search for a string "dbdir=" and append / write the installdir after that string.

So here's my code:

SetOutPath "$INSTDIR\somewhere"
        FileOpen $1 "file.ini" a
        FileSeek $1 "dbdir="
        FileWrite $1 "$INSTDIR\path\to\somwhere"
        FileClose $1 
Sadly the string is written at the beginning of the file.
What am I doing wrong?
jpderuiter#
FileSeek does not search for textstring, it just does place the cursor at a specified location.
You probably want to use WriteConfig: http://nsis.sourceforge.net/Docs/App...ml#configwrite
ascTim#
Thanks for your reply.

Sounds like this is exactly what I am looking for.

So it will look like this:

${ConfigWrite} "$INSTDIR\somwhere\file.ini" "dbdir=" "$INSTDIR\path\to\somewhere" $R0 
When compiling it says "Invalid command: ${ConfigWrite}"
Anders#
Originally Posted by ascTim View Post
When compiling it says "Invalid command: ${ConfigWrite}"
You need to include the .nsh that function lives in but if this is a normal .ini file you can just use the NSIS ini instructions.
ascTim#
Yup figured that out. Works perfectly now! 🙂

Thanks once again to you guys.


Have a great week 🙂