Search code examples
windows-installerinstallationnsis

Nullsoft InstallDir invalid parameters


This is my first time using NSIS and I'm having a bit of difficulty.

I'd like to install my program under a directory with the product name, followed by the version number. So I gave this a try:

!define PRODUCT_NAME "My Prog"
!define SETUP_NAME "My Prog Setup"
!define PRODUCT_VERSION "SW-00134-00"

!define EXECUTABLE_NAME "MyProg.exe"
!define SHORTCUT_NAME "MyProg.lnk"

!define INSTALL_FOLDER "C:\Code32\${PRODUCT_NAME}\${PRODUCT_VERSION}\"


; The name of the installer
Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"

; The file to write
OutFile "${SETUP_NAME} ${PRODUCT_VERSION}.exe"

; The default installation directory
InstallDir ${INSTALL_FOLDER}

However, this results in the error InstallDir expects 1 parameters, got 3 at the last line. I'm assuming because the preprocessor is doing a string replacement and therefore InstallDir is seeing 3 arguments instead of 1, but I don't have a clue what I'm talking about this early in the game.


Solution

  • Yes the compiler removes the outer set of quotes if present so after preprocessing the InstallDir instruction ends up as InstallDir C:\Code32\My Prog\SW-00134-00\.

    To fix it just quote the InstallDir parameter:

    InstallDir "${INSTALL_FOLDER}"