Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSIS IfFileExists - more than one line

Tags:

nsis

I'm using the IfFileExists function but I think it only include the first line after the jump. How can I do something similar to C like {..../.../....}?!

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"
like image 832
metRo_ Avatar asked Sep 14 '12 10:09

metRo_


1 Answers

The syntax of IfFileExists is

IfFileExists file_to_check offset_or_label_if_exists [offset_or_label_if_not_exists]

If you plan to execute either a block or another block, don't forget to jump over the second block.

Thus a simple case would be:

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:

If one of the block is just after the IfFileExists you can use a 0 offset instead of a useless label:

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:
like image 172
Seki Avatar answered Sep 29 '22 15:09

Seki