Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4111444
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T22:04:01+00:00 2026-05-20T22:04:01+00:00

I would like to know how to use a YESNOCANCEL MessageBox in conjunction with

  • 0

I would like to know how to use a YESNOCANCEL MessageBox in conjunction with IF logic from LogicLib.nsh in NSIS installer scripting to avoid having to use labels and gotos.

Is there any way to capture the result of a MessageBox in a variable of some kind?

Also, I know there are better things than NSIS out there, but using something else isn’t a possibility at this point. =(

Note the {WHAT GOES HERE??} in the below code. If this was just an If…Else… it would work fine.

Thanks for the help

${If} ${Cmd} `MessageBox MB_YESNOCANCEL|MB_ICONEXCLAMATION 
"PROGRAM X is already installed. Click YES to remove the installed version 
 found in C:\Program Files(x86). Click NO to skip uninstall and choose a 
 different install location (not recommended) or CANCEL to terminate
  the installer." IDYES`

    MessageBox MB_OK "Yes was clicked"
${ElseIf} {WHAT GOES HERE??}
    MessageBox MB_OK "No was clicked"
${Else}    
    MessageBox MB_OK "Cancel was clicked"
${EndIf}  

Update:
I also found this example, but I am not sure what ${||} does or how it might help me.

  ; ifcmd..||..| and if/unless cmd
  StrCpy $R2 ""
  ${IfCmd} MessageBox MB_YESNO "Please click Yes" IDYES ${||} StrCpy $R2 $R2A ${|}
  ${Unless} ${Cmd} `MessageBox MB_YESNO|MB_DEFBUTTON2 "Please click No" IDYES`
    StrCpy $R2 $R2B
  ${EndUnless}
  ${If} $R2 == "AB"
    DetailPrint "PASSED IfCmd/If Cmd test"
  ${Else}
    DetailPrint "FAILED IfCmd/If Cmd test"
  ${EndIf}  
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T22:04:02+00:00Added an answer on May 20, 2026 at 10:04 pm

    A line ending in ${|} indicates a if block that executes a single instruction if the condition is true:

    ${IfThen} $Instdir == $Temp ${|} MessageBox mb_ok "$$InstDir equals $$Temp" ${|}
    

    This is just shorthand syntax for:

    ${If} $Instdir == $Temp 
        MessageBox mb_ok "$$InstDir equals $$Temp" 
    ${EndIf}
    

    The IfCmd macro uses ${IfThen} ${Cmd} internally and ${||} is a hack to end the string quote started by IfCmd, so:

    ${IfCmd} MessageBox MB_YESNO "click yes" IDYES ${||} MessageBox mb_ok choice=IDYES ${|}
    

    is shorthand for:

    ${If} ${Cmd} 'MessageBox MB_YESNO "yes" IDYES' ;notice the quotes here
        MessageBox mb_ok choice=IDYES
    ${EndIf}
    

    You can even mix ifthen and labels, but this is ugly IMHO:

    StrCpy $0 "Cancel"
    ${IfCmd} MessageBox MB_YESNOCANCEL "Mr. Powers?" IDYES yes IDNO ${||} StrCpy $0 "NO?!" ${|}
    MessageBox mb_iconstop $0 ;Cancel or NO
    goto end
    yes:
    MessageBox mb_ok "Yeah baby yeah!"
    end:
    

    (It is better to just use labels with MessageBox for YESNOCANCEL and ABORTRETRYIGNORE, for YESNO, OKCANCEL etc. that execute different code for both choices, use the ${If} ${Cmd} ‘MessageBox ..’ .. ${Else} .. ${EndIf} syntax)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to know how to use Queue in the best functional way.
I would like to know if I can use the following JQuery function on
I would like to know how can I use tinyint in SQL Server 2005
I would like to know how can I use jQuery to select multiple items
I would like to know a few practical use-cases (if they are not related/tied
I would like to know if it is safe to use the following code
I would like to know: If it's possible to use Lazarus (Pascal) for both
I would like to know what solution I can use in order to have
I would like to know if it is possible to use canvases and javascript
I would like to know if is better to use application/javascript or application/ecmascript and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.