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

Nat*_*hes 3 nsis constants

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

; -*-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
Run Code Online (Sandbox Code Playgroud)

这会导致以下错误消息(在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
Run Code Online (Sandbox Code Playgroud)

如果我用15替换第15行

File c:\users\nhughes\foo\foo.bat
Run Code Online (Sandbox Code Playgroud)

和第18行

  "c:\users\nhughes\foo\foo_logo.ico"
Run Code Online (Sandbox Code Playgroud)

然后它工作正常.

Fem*_*emi 6

请尝试使用${FOO_SRC}.