Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSIS: Reading from a file at compile time

I want to read some values from a file (config.json) into some variables when I compile my nsis script. How can I possibly do that?

Thanks in advance.

like image 267
foobar Avatar asked Oct 20 '25 10:10

foobar


2 Answers

The !include command can include any file (at compile time) at the point where it is placed in the nsis script. But the included file must be compliant with the nsis syntax (e.g. it should !define some values).

The !execute command could help you: if you need absolutely to process a json file you could code a third-party batch command file to pre-process the json file and translate it into a suitable nsis file.

like image 69
Seki Avatar answered Oct 23 '25 13:10

Seki


You can use !define to pass some value which can be used in compile time. For example lets imagine that you have got this code in you nsis source file:

!define PATHTOFILE "C:\thisfilewillbedeleted.ext"
Delete $PATHTOFILE

If you want to change this walue on compile time you can call nsis in this way:

makensis /DPATHTOFILE="C:\otherfiletodelete.ext"

[EDIT]

If you got *.json file which is generated using external tool and you must use this kind of file I will suggest you to use some building system, for example ant. You can create build.xml which read, parse data from json file and then write those data to *.nsh file. I think it will be better and cleaner than do it all in nsis script.

like image 38
pepuch Avatar answered Oct 23 '25 13:10

pepuch



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!