Search code examples
nsismessagebox

NSIS | Message Box | Displaying Text and Variable


I am new to NSIS and I wanted to show a message with a text and a variable value (mainly for debugging purpose). Please let me know if this can be achieved by the following method

Example: MessageBox MB_OK "Application Name" $VersionNumber

If this method is not correct please suggest an alternative.


Solution

  • The MessageBox string needs quotes (", ' or `) if it contains spaces.

    !define COPYYEAR 2018
    
    Var VersionNumber
    
    Section
    StrCpy $VersionNumber "1.2.3.4" ; You will probably read this from somewhere, not hardcode it
    MessageBox MB_OK "Application Name $VersionNumber"
    MessageBox MB_OK NoSpacesNoQuotesRequired$VersionNumber
    MessageBox MB_OK|MB_ICONINFORMATION "Copyright (R) ${COPYYEAR}"
    SectionEnd