Frage

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 ?

War es hilfreich?

Lösung

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
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top