Question

I have this NSIS script:

Section "!${SECTION_MAIN}" sectionMainID
    SetOutPath "$INSTDIR"
    whileRuns:
                LockedList::FindProcess "$INSTDIR\bin\${PRODUCT_NAME}.exe"
                Pop $R0
                ${If} $R0 != ``
                      MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION "this is running. Please close it first."  IDOK OK IDCANCEL CANCEL 
                      OK:
                         Goto whileMLRuns
                      CANCEL:
                         Abort
                ${EndIf}

I would like to change it to silent mode. In silent mode, i would like that automatically messagebox is ended with a CANCEL. so, according to doc, i put a /SD flag, with the command IDCANCEL in the end of line with MessageBox inside. Like that :

Section "!${SECTION_MAIN}" sectionMainID
    SetOutPath "$INSTDIR"
    whileRuns:
                LockedList::FindProcess "$INSTDIR\bin\${PRODUCT_NAME}.exe"
                Pop $R0
                ${If} $R0 != ``
                      MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION "this is running. Please close it first."  IDOK OK IDCANCEL CANCEL /SD IDCANCEL
                      OK:
                         Goto whileMLRuns
                      CANCEL:
                         Abort
                ${EndIf}

However, this is failing. So, I changed it to

Section "!${SECTION_MAIN}" sectionMainID
    SetOutPath "$INSTDIR"
    whileRuns:
                LockedList::FindProcess "$INSTDIR\bin\${PRODUCT_NAME}.exe"
                Pop $R0
                ${If} $R0 != ``
                      MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION "this is running. Please close it first."  IDOK OK IDCANCEL CANCEL /SD CANCEL
                      OK:
                         Goto whileMLRuns
                      CANCEL:
                         Abort
                ${EndIf}

with now CANCEL instead of IDCANCEL in the same line. This is because with this syntax it is branched with the same syntax as in user interaction mode. However, it seems not to be working either.

What is wrong with my flag, how can i fix that ? Should i use a syntax with a jump instead ?

Was it helpful?

Solution

I think the parameter order does matter. Try to use IDCANCEL with following order:

MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION "a-message" /SD IDCANCEL IDOK OK IDCANCEL CANCEL
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top