Archive: How to write variable to txt or bat file


How to write variable to txt or bat file
i would like to write some text and variables into a txt file.. so how to create file myfile.txt and write tekst ('my text') + variable(for example $INSTDIR) to file?? i know that it is possibel to write to ini, but i really need txt(or bat file)


See FileOpen, FileWrite and FileClose in the documentation.

There are also some examples in the Archive.


There are also a lot of functions for text file manipulation on the NSIS Archive.

-Stu


is it possible to use the INI-functions on any text file (not only *.ini) ?
it might be the better way !?


Yes it is, you can make ini entries in not just .ini files.

You can also write $\r$\n to the end of the ini value to make a few nice gaps between entries or entry groups too hence while making logs.

-Stu


I wouldn't use it. You can never know what the function will do with the data that's not structured as an INI file.


tnx :) it works, but it is strange, that in NSIS you can unite variable and string this strange way(without '+' or smth like that):
FileWrite $1 '"$INSTDIR" is installation directory'
output: "c:\program files" is installation directory
it is fine to me, but what if i wanted to get this output:
output2: "$INSTDIR" is installation directory
(right now i don't need this output, but i was just wondering)
anyway tnx again


ok, i just figured it out:
FileWrite $1 '"$'
FileWrite $1 'INSTDIR" is installation directory'


The proper way to get NSIS to not process the dollar sign is to use two dollars. For example:

FileWrite $1 '"$$INSTDIR" is installation directory'