Search code examples
nsis

NSIS variable not allowed space in define variable


 **define POSTGRESQL_INSTALLATION_DIRECTORY "C:\Program Files\Postgre SQL\9.3"**

NSIS varible not allowed space in below declared variable.

[INFO] [MAKENSIS] DetailPrint expects 1 parameters, got 2.
[INFO] [MAKENSIS] Usage: DetailPrint message
[ERROR] Failed to execute goal org.codehaus.mojo:nsis-maven-plugin:1.0-SNAPSHOT:compile (64bit_REACH) on project dsr.installer: Execution of makensis compiler failed. See output above for details. -> [Help 1]

It works fine if i define variable without space like:

 `**define POSTGRESQL_INSTALLATION_DIRECTORY "C:\ProgramFiles\PostgreSQL\9.3"**`

But i want space between the declared variable like

`**define POSTGRESQL_INSTALLATION_DIRECTORY "C:\Program Files\Postgre SQL\9.3"**` 

So please let me know how to execute this defined variable.


Solution

  • The compiler is telling you the problem, the DetailPrint instruction takes 1 parameter and when a string with spaces is not quoted correctly it will be interpreted as multiple parameters.

    !define POSTGRESQL_INSTALLATION_DIRECTORY "C:\Program Files\PostgreSQL\9.3"
    
    Section
    ;DetailPrint ${POSTGRESQL_INSTALLATION_DIRECTORY} ; This will not work because the string is not quoted
    DetailPrint "${POSTGRESQL_INSTALLATION_DIRECTORY}"
    DetailPrint '${POSTGRESQL_INSTALLATION_DIRECTORY}'
    DetailPrint "Hello ${POSTGRESQL_INSTALLATION_DIRECTORY} World"
    DetailPrint 'Hello "${POSTGRESQL_INSTALLATION_DIRECTORY}" World'
    DetailPrint "Hello $\"${POSTGRESQL_INSTALLATION_DIRECTORY}$\" World"
    SectionEnd