NSIS IfFileExists - More than One Line

I use the IfFileExists function, but I think that it only includes the first line after the jump. How can I do something similar to C, for example {.... / ... / ....} ?!

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" 
+4
source share
1 answer

The syntax for IfFileExists is

 IfFileExists file_to_check offset_or_label_if_exists [offset_or_label_if_not_exists] 

If you plan to execute a block or another block, be sure to jump over the second block.

So a simple case:

 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 blocks is right after IfFileExists , you can use an offset of 0 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: 
+11
source

Source: https://habr.com/ru/post/1434169/


All Articles