Hi,
I want to do something like
---------
IfFileExists "$INSTDIR\Manual\*.*"
{
CreateDirectory "$SMPROGRAMS\MySoft\${PRODUCT}\Help"
IfFileExists "$INSTDIR\Manual\Manual.html" "" +2
CreateShortCut "$SMPROGRAMS\MySoft\${PRODUCT}\Help\Manual (English).lnk" "$INSTDIR\Manual\Manual.html" "" "$INSTDIR\Manual\Manual.html" 0
}
---------
How can I do this "{ }" (begin-end) sort of thing with NSIS syntax? I've tried it with the labels with no success.
Also, I've seen that in makensis.nsi you add a "+2" as a parameter of IfFileExists. Why is that?
IfFileExists
6 posts
Try this code:
Vytautas
+2 means that the installer should skip the next 2 lines.
IfFileExists "$INSTDIR\Manual\*.*" 0 NotFileExisted
CreateDirectory "$SMPROGRAMS\MySoft\${PRODUCT}\Help"
IfFileExists "$INSTDIR\Manual\Manual.html" "" +2
CreateShortCut "$SMPROGRAMS\MySoft\${PRODUCT}\Help\Manual (English).lnk" \
"$INSTDIR\Manual\Manual.html" "" "$INSTDIR\Manual\Manual.html" 0
NotFileExisted:
Vytautas
Yes, I tried something similar but it didn't work. This is my current code:
What I want to do is, add a shortcut in the start menu to a manual (.html file) ONLY if the manual was installed. Manual installation is optional, it is in a section:
Section $(TITLE_StartMenuShortCuts) StartMenuShortCuts
CreateDirectory "$SMPROGRAMS\MySoft\${PRODUCT}"
IfFileExists "$INSTDIR\Manual\*.*" 0 NotFileExisted
CreateDirectory "$SMPROGRAMS\MySoft\${PRODUCT}\Help"
IfFileExists "$INSTDIR\Manual\Manual.html" "" +2
CreateShortCut "$SMPROGRAMS\MySoft\${PRODUCT}\Help\Manual (English).lnk" "$INSTDIR\Manual\Manual.html" "" "$INSTDIR\Manual\Manual.html" 0
NotFileExisted:
CreateShortCut "$SMPROGRAMS\MySoft\${PRODUCT}\${PRODUCT}.lnk" "$INSTDIR\${PRODUCT_EXENAME}" "" "$INSTDIR\${PRODUCT_EXENAME}" 0
CreateShortCut "$SMPROGRAMS\MySoft\${PRODUCT}\Uninstall ${PRODUCT}.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0
SectionEnd
If I can't use IfFileExists to check if the manual was installed, can I at least check if the section of the english manual was checked for installation? The problem is that I will have multiple translations of the manual so it will be something like:
SubSection $(TITLE_Manual) Manual
Section $(TITLE_ManualEnglish) ""
SetOutPath $INSTDIR\Help
File "${FILESPATH}\Help\Manual.html"
SectionEnd
SubSectionEnd
So I will need to check if at least one of the manual translations was checked to install.
SubSection $(TITLE_Manual) Manual
Section $(TITLE_ManualEnglish) ""
SetOutPath $INSTDIR\Help
File "${FILESPATH}\Help\Manual.html"
SectionEnd
Section $(TITLE_ManualLanguageX) ""
SetOutPath $INSTDIR\Help
File "${FILESPATH}\Help\ManualLANGX.html"
SectionEnd
...
SubSectionEnd
You should use the LogicLib. See Examples\LogicLib.nsi and search for FileExists. It will be much easier.
Thanks for the tip. I finally decided to give up FileExists and use variables to know if the person decided to install X translation of the help file. Ej. something like
- Is there an easier way to use boolean variables without using StrCpy?
- Is there an easier way to check if a section was selected for installation?
- How can I do something like:
and then, on the create shortcuts section:
SubSection $(TITLE_Manual) Manual
var "ManualEnglish"
var "ManualLangX"
; I use this to initialize variables
Section "" ""
StrCpy $ManualEnglish "F"
StrCpy $ManualLangX "F"
SectionEnd
Section $(TITLE_ManualEnglish) ""
StrCpy $ManualEnglish "T"
SetOutPath $INSTDIR\Help
File "${FILESPATH}\Help\Manual.html"
SectionEnd
Section $(TITLE_ManualLangX) ""
StrCpy $ManualLangX "T"
SetOutPath $INSTDIR\Help
File "${FILESPATH}\Help\ManualLangX.html"
SectionEnd
My questions:
${If} $ManualEnglish == "T"
CreateShortCut "$SMPROGRAMS\MySoft\${PRODUCT}\Help\Manual (English).lnk" "$INSTDIR\Manual\Manual.html" "" "$INSTDIR\Manual\Manual.html" 0
${EndIf}
${If} $ManualLangX == "T"
CreateShortCut "$SMPROGRAMS\MySoft\${PRODUCT}\Help\Manual (Español).lnk" "$INSTDIR\Manual\ManualLangX.html" "" "$INSTDIR\Manual\ManualLangX.html" 0
${EndIf}
- Is there an easier way to use boolean variables without using StrCpy?
- Is there an easier way to check if a section was selected for installation?
- How can I do something like:
I need that because I need to create the main "Help" entry in the start menu only if at least one of the translations of the manual were selected to install.
${If} $ManualEnglish == "T" ${or} $ManualLangX == "T"
CreateDirectory "$SMPROGRAMS\MySoft\${PRODUCT}\Help"
Is there an easier way to use boolean variables without using StrCpy?No.
Is there an easier way to check if a section was selected for installation?Use LogicLib's ${SectionIsSelected}.
How can I do something like...Maybe: if condition 1, add 1 to some var; if condition 2, add 1 to some var; if some var = 2, create directory. With StrCmp it's a lot easier:
StrCmp $0 T 0 skip
StrCmp $1 T 0 skip
CreateDirectory ...
skip: