3

我是 NSIS 的新手,我正在尝试在安装时执行可执行文件,类似于预请求。我尝试了下面的代码,它将 exe 复制到安装路径,但它没有执行它。

Section "example" example
  SetOutPath "$INSTDIR"
  File "setup.exe"
  Exec "$INSTDIR\setup.exe"
  BringToFront
SectionEnd 
4

2 回答 2

8

The answer from Seki is mostly correct, I'd just like to add that the correct syntax for Exec/ExecWait is always Exec '"c:\path\app.exe" param1 "par am2" param3'

Parameters are of course optional but the path to the app should always be quoted, not just because in your case where $INSTDIR could contain spaces but at least on Win9x it will fail no matter what if you don't quote (According to the NSIS manual)

If the spaces/lack of quotes is not the issue then there are a couple of other things you might want to look into:

  • $OUTDIR is the working directory for the new process (SetOutPath sets this)
  • Missing dll's etc (Check with Process Monitor)
于 2012-06-05T15:27:05.693 回答
2

变量是否$INSTDIR映射到名称包含空格的目录?如果是这样,您应该添加简单引号以将双引号包含到Exec参数中:

Exec '"$INSTDIR\setup.exe"'
于 2012-06-05T13:05:19.293 回答