(1)
这个
File
指令不是这样工作的,它不接受变量,因为文件名引用了您正在编译的计算机上的文件。文件被压缩并存储在安装程序中。exe。使用
CopyFiles
复制已在最终用户系统上的文件的说明。
要有条件地提取某些内容,您需要编写如下内容:
!include LogicLib.nsh
Section
SetOutPath $InstDir
${If} $myvar == "something.ext"
File "something.ext"
${Else}
File "somethingelse.ext"
${EndIf}
SectionEnd
(2)
FileRead
包括换行符(如果有),必须删除它们:
; Write example file
FileOpen $0 "$temp\nsistest.txt" w
FileWrite $0 "hello$\r$\n"
FileWrite $0 "world$\r$\n"
FileClose $0
; Parse file
FileOpen $0 "$temp\nsistest.txt" r
loop:
FileRead $0 $1
StrCmp $1 "" done
StrCpy $2 $1 "" -1 ; Copy last character
StrCmp $2 '$\r' +2
StrCmp $2 '$\n' +1 +3
StrCpy $1 $1 -1 ; Remove newline
Goto -4 ; ...and check the end again
DetailPrint line=$1
Goto loop
done:
FileClose $0