Ami
Ami

Reputation: 4259

How can I read property file at run time using NSIS script?

I have a .property file in my Java project. In that property file have more than 20 values. Now I want to parse that property file and change the specific property value at run time(that is when run the install file). I have used following code

Section
    ${ConfigWrite} "C:resource\conf.properties" SET WEBSERVICE.URL=http://localhost:8080 $R0
    ;$R0=CHANGED
SectionEnd

After running exe file ,the property added in property file like this

  SETSERVER.URL=http://localhost:8080

I don't know why the SET words comes before this variable?

My requirements:

  1. I need to give value for SERVER.URL property at run time (while installing the exe file)?

  2. I need to replace the value of SERVER.URL property.but Using above added one more new property in that file.

I have used NSIS plugin in Eclipse on Windows platform.

Upvotes: 0

Views: 1211

Answers (1)

Seki
Seki

Reputation: 11465

You are missing some quotes when calling the macro, also there is no need to specify SET (in the example from help, SET is actually part of a command in a DOS batch file), and I guess that it is better to add a backslash to the path after the disk drive.

The doc states that the syntax is:

${ConfigWrite} "[File]" "[Entry]" "[Value]" $var

Therefore your call must be:

${ConfigWrite} "C:\resource\conf.properties" "WEBSERVICE.URL" "=http://localhost:8080" $0

Note how the parameters are splitted between the parameter name WEBSERVICE.URL and the value =http://localhost:8080 (note the equal sign at the beginning).

You can make the directories dynamic too:

${ConfigWrite} "$INSTDIR\resource\conf.properties" "WEBSERVICE.URL" "=http://localhost:8080" $0

Upvotes: 1

Related Questions