NSIS IfFileExists - 不止一行

met*_*Ro_ 6 nsis

我正在使用IfFileExists函数,但我认为它只包含跳转后的第一行.我怎样才能做类似C的事情,比如{..../.../....}?!

IfFileExists "$PROGRAMFILES\InduSoft Web Studio v7.0\Bin\RunStartUp.exe" StartUpExists PastStartUpExists
      StartUpExists:
        StrCpy $Text "$PROGRAMFILES\InduSoft Web Studio v7.0\Bin\RunStartUp.exe"

      PastStartUpExists:
        nsDialogs::Create 1018
        Pop $Dialog

        nsDialogs::SelectFileDialog open "$PROGRAMFILES\InduSoft Web Studio v7.0\Bin\RunStartUp.exe" "*.exe"

        Pop $Text

        ${NSD_CreateText} 0 13u 100% -13u $Text
        Pop $Text

        ${NSD_CreateText} 0
        ${NSD_GetText} $Text $0

        CreateShortCut "$SMPROGRAMS\Advanlab\Website.lnk" "$INSTDIR\${PRODUCT_NAME}.url"
        CreateShortCut "$SMPROGRAMS\Advanlab\Uninstall.lnk" "$INSTDIR\uninst.exe"
        CreateShortCut "$SMPROGRAMS\Advanlab\Advanlab.lnk" "$0"
        CreateShortCut "$DESKTOP\Advanlab.lnk" "$0"
Run Code Online (Sandbox Code Playgroud)

Sek*_*eki 16

语法IfFileExists

IfFileExists file_to_check offset_or_label_if_exists [offset_or_label_if_not_exists]
Run Code Online (Sandbox Code Playgroud)

如果您计划执行或者另一块,不要忘记跳过第二块.

因此,一个简单的案例是:

IfFileExists "$INSTDIR\file.txt" file_found file_not_found
file_found:
StrCpy $0 "the file was found"
goto end_of_test ;<== important for not continuing on the else branch
file_not_found:
StrCpy $0 "the file was NOT found"
end_of_test:
Run Code Online (Sandbox Code Playgroud)

如果其中一个块就在IfFileExists您之后,则可以使用0偏移而不是无用标签:

IfFileExists "$INSTDIR\file.txt" 0 file_not_found
StrCpy $0 "the file was found"
goto end_of_test ;<== important for not continuing on the else branch
file_not_found:
StrCpy $0 "the file was NOT found"
end_of_test:
Run Code Online (Sandbox Code Playgroud)