如何使用常量在NSIS中指定文件路径?

时间:2011-08-10 17:23:32

标签: constants nsis

我想使用常量指定要安装的文件所在的目录,如下所示:

; -*-nsis-*-

Name "ndhtest"
OutFile "FooStartMenuTest.exe"

!define FOO_SRC c:\users\nhughes\foo

InstallDir "$PROGRAMFILES\Initech\"

Page instfiles
Section
  SetOutPath $INSTDIR
  File "$FOO_SRC\foo.bat"    ;; <-- line 15 here
  CreateDirectory $SMPROGRAMS\Initech
  CreateShortCut $SMPROGRAMS\Initech\Foo.lnk $INSTDIR\foo.bat "" \
    "$FOO_SRC\foo_logo.ico"  ;; <-- line 18 here
SectionEnd

这会导致以下错误消息(在emacs中,使用nsis-mode):

Processing script file: "c:/users/nhughes/STARTM~1.NSI"
Name: "ndhtest"
OutFile: "FooStartMenuTest.exe"
XPStyle: on
!define: "FOO_SRC"="c:\users\nhughes\foo"
InstallDir: "$PROGRAMFILES\Initech\"
Page: instfiles
Section: ""
SetOutPath: "$INSTDIR"
File: "$FOO_SRC\foo.bat" -> no files found.
Usage: File [/nonfatal] [/a] ([/r] [/x filespec [...]] filespec [...] |
   /oname=outfile one_file_only)
Error in script "c:/users/nhughes/STARTM~1.NSI" on line 15 -- aborting creation process

如果我用

替换第15行
File c:\users\nhughes\foo\foo.bat

和第18行

  "c:\users\nhughes\foo\foo_logo.ico"

然后它运作正常。

1 个答案:

答案 0 :(得分:6)

请尝试使用${FOO_SRC}