3
votes

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.

3
It will work with the variable inside the quotes - idleberg

3 Answers

1
votes

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
0
votes

If your are just wanting to display the 'OK' button, try this:

MessageBox MB_OK "Application Name= ${VersionNumber}"

References: NSIS MessageBox and Chapter 2: Tutorial: The Basics

Note: The entire message that is to be displayed, including any variables, must be encased in quotes.

0
votes

There is a free tool exactly for this purpose called MessageBox Designer. You can get it as a part of Visual & Installer package (https://visual-installer.com/features.html#messagebox-designer).

I allows you to create MessageBox-es easily with intuitive GUI and generates script for you.

P.S. I am author of this tool (sorry for a little self promo :)