使用nsDialog的listview安装文件
Using nsDialog's listview to install files
我有一个包含以下行的 .txt 文件:
- app1
- app2
- app3
- ...
- appN
在我制作安装程序之前,我在 ${srcdir} 中也有这个文件:
- ${srcdir}\app1
- ${srcdir}\app2
- ${srcdir}\app3
- ...
- ${srcdir}\appN
文件列表总是在变化,所以我需要手动更正 nsi 脚本。
如何使用取决于 file.txt 的列表视图在自定义页面上制作复选框列表?
现在我正在使用组件页面和简单的构造来检查文件。
SectionGroup /e "Installing apps" SecApps
!if /FileExists "E:\src\app.dll"
Section "Install app1"
SetOutPath "$InstDir"
File "E:\src\app.dll"
SectionEnd
!endif
!if /FileExists "E:\src\app2.dll"
Section "Install app2"
SetOutPath "$InstDir"
File "E:\src\app2.dll"
SectionEnd
!endif
!if /FileExists "E:\src\app3.dll"
Section "Install app3"
SetOutPath "$InstDir"
File "E:\src\app3.dll"
SectionEnd
!endif
SectionGroupEnd
当你想在编译时做一些高级的事情时,最好的选择通常是用 !system
:
调用外部 script/application
!define srcdir "."
; Make some dummy files for this example
!appendfile "${srcdir}\foo.txt" "!"
!appendfile "${srcdir}\bar.txt" "!"
!delfile /nonfatal "${srcdir}\filelist.txt"
!appendfile "${srcdir}\filelist.txt" "foo.txt$\r$\n"
!appendfile "${srcdir}\filelist.txt" "bar.txt$\r$\n"
; Make batch file for this example (In a real installer you probably don't want to generate the .bat on the fly like this)
!define /redef batch "${__FILE__}\..\parsefile.bat"
!delfile /nonfatal "${batch}"
!appendfile "${batch}" "@echo off&setlocal ENABLEEXTENSIONS$\r$\n"
!appendfile "${batch}" `for /F "usebackq" %%A in ("%~2") do ($\r$\n`
!appendfile "${batch}" ' >> %1 echo Section "%%~nA"$\r$\n'
!appendfile "${batch}" ' >> %1 echo File "%%A"$\r$\n'
!appendfile "${batch}" ' >> %1 echo SectionEnd$\r$\n'
!appendfile "${batch}" ")$\r$\n"
!tempfile nsh
!system '"${batch}" "${nsh}" "${srcdir}\filelist.txt"' = 0
!include "${nsh}"
!delfile "${nsh}"
!undef nsh
Page Components
Page InstFiles
我有一个包含以下行的 .txt 文件:
- app1
- app2
- app3
- ...
- appN
在我制作安装程序之前,我在 ${srcdir} 中也有这个文件:
- ${srcdir}\app1
- ${srcdir}\app2
- ${srcdir}\app3
- ...
- ${srcdir}\appN
文件列表总是在变化,所以我需要手动更正 nsi 脚本。
如何使用取决于 file.txt 的列表视图在自定义页面上制作复选框列表?
现在我正在使用组件页面和简单的构造来检查文件。
SectionGroup /e "Installing apps" SecApps
!if /FileExists "E:\src\app.dll"
Section "Install app1"
SetOutPath "$InstDir"
File "E:\src\app.dll"
SectionEnd
!endif
!if /FileExists "E:\src\app2.dll"
Section "Install app2"
SetOutPath "$InstDir"
File "E:\src\app2.dll"
SectionEnd
!endif
!if /FileExists "E:\src\app3.dll"
Section "Install app3"
SetOutPath "$InstDir"
File "E:\src\app3.dll"
SectionEnd
!endif
SectionGroupEnd
当你想在编译时做一些高级的事情时,最好的选择通常是用 !system
:
!define srcdir "."
; Make some dummy files for this example
!appendfile "${srcdir}\foo.txt" "!"
!appendfile "${srcdir}\bar.txt" "!"
!delfile /nonfatal "${srcdir}\filelist.txt"
!appendfile "${srcdir}\filelist.txt" "foo.txt$\r$\n"
!appendfile "${srcdir}\filelist.txt" "bar.txt$\r$\n"
; Make batch file for this example (In a real installer you probably don't want to generate the .bat on the fly like this)
!define /redef batch "${__FILE__}\..\parsefile.bat"
!delfile /nonfatal "${batch}"
!appendfile "${batch}" "@echo off&setlocal ENABLEEXTENSIONS$\r$\n"
!appendfile "${batch}" `for /F "usebackq" %%A in ("%~2") do ($\r$\n`
!appendfile "${batch}" ' >> %1 echo Section "%%~nA"$\r$\n'
!appendfile "${batch}" ' >> %1 echo File "%%A"$\r$\n'
!appendfile "${batch}" ' >> %1 echo SectionEnd$\r$\n'
!appendfile "${batch}" ")$\r$\n"
!tempfile nsh
!system '"${batch}" "${nsh}" "${srcdir}\filelist.txt"' = 0
!include "${nsh}"
!delfile "${nsh}"
!undef nsh
Page Components
Page InstFiles