Hi...I stopped using NSIS about an year ago. I know that then it was not possible to define in an .ini file which files the NSIS executable should contain.
So, my question is this: Is it possible to tell the NSIS compiler to get the files from an .ini file.
I want to have a generic setup script to install some patches for my application. And because different patches may contain different files, I do not want to be forced to reedit the script when those files change. I want just to edit an .ini file and the NSIS compiler should look at that file and get from there the files.
Thank you.
How to get what files to install on compile time?
12 posts
Create another NSIS installer which is executed at compile time to use ReadINIStr and write a list of NSIS File instructions in a seperate .nsi file which is later !include-d by the main .nsi script.
-Stu
Thank you. I will try that.
If you're going to use Afrow's RecFind you'll make your life easy. :-)
1. Create the header
1. Create the header
2. Create your Installation!define PatchDir 'D:\Patch1'
!define Header 'Patch1_Files.nsh'
OutFile 'CreateHeader.exe'
!include RecFind.nsh
Section
SetOutPath '$EXEDIR'
FileOpen $R2 ${Header} w
${RecFindOpen} "${PatchDir}" $R0 $R1
${RecFindFirst}
FileWrite $R2 'File "${PatchDir}$R0\$R1"$\r$\n'
${RecFindNext}
${RecFindClose}
FileClose $R2
SectionEnd
This way you only need to edit the two defines each time you want to add a new patch. :-)!define Header 'Patch1_Files.nsh'
!system CreateHeader.exe
!include ${Header}
Nice script Red Wine!
Just one thing though,
!include ${Header}
-Stu
Just one thing though,
!include ${Header}
-Stu
Thank you. I am glad that there is a solution for my problem. I will try to do this a.s.a.p
@ Stu
hmm a typo! that's me! :-)
@ Chilli24
to include subdirs as well place the line bellow under ${RecFindOpen} "${PatchDir}" $R0 $R1:
FileWrite $R2 'SetOutPath "$$INSTDIR$R0"$\r$\n'
hmm a typo! that's me! :-)
@ Chilli24
to include subdirs as well place the line bellow under ${RecFindOpen} "${PatchDir}" $R0 $R1:
FileWrite $R2 'SetOutPath "$$INSTDIR$R0"$\r$\n'
Section
SetOutPath '$EXEDIR'
FileOpen $R2 ${Header} w
${RecFindOpen} "${PatchDir}" $R0 $R1
FileWrite $R2 'SetOutPath "$$INSTDIR$R0"$\r$\n'
${RecFindFirst}
FileWrite $R2 'File "${PatchDir}$R0\$R1"$\r$\n'
${RecFindNext}
${RecFindClose}
FileClose $R2
SectionEnd
Just posted an article at wiki
It is also possible to compile and run a premade script from your installer at compile time:
[edit]Typo: 'bellow' is spelled 'below' 🙂 [/edit]
CreateHeader.nsi contains the code above by Red Wine, and remove the top two lines of the script as they are defined on the command line 🙂. Now all you have to change is the patch type at the top of my script 🙂.!define PatchType 'Patch1_Files'
!define PatchPath 'C:\${PatchType}'
!system '"${NSISDIR}\makensis.exe" /D PatchDir "${PatchPath}" /D Header "${PatchType}" "CreateHeader.nsi"'
!system 'CreateHeader.exe'
Section
!include '${PatchType}.nsh'
SectionEnd
[edit]Typo: 'bellow' is spelled 'below' 🙂 [/edit]
Sorry, just found an error: forgot the extenstion on the command line.
Just ran out of time to edit my post, so I replied again.!define PatchType 'Patch1_Files'
!define PatchPath 'C:\${PatchType}'
!system '"${NSISDIR}\makensis.exe" /D PatchDir "${PatchPath}" /D Header "${PatchType}.nsh" "CreateHeader.nsi"'
!system 'CreateHeader.exe'
Section
!include '${PatchType}.nsh'
SectionEnd
@ Jason
I really appreciate your notice for my spelling, though, don't expect I will not do it again.:-)
If you don't mind, please contribute your extension on the above mentioned article
regards
I really appreciate your notice for my spelling, though, don't expect I will not do it again.:-)
If you don't mind, please contribute your extension on the above mentioned article
regards
Will do. [edit] Done. [/edit]