我是 NSIS 的新手,我正在尝试在安装时执行可执行文件,类似于预请求。我尝试了下面的代码,它将 exe 复制到安装路径,但它没有执行它。
Section "example" example
SetOutPath "$INSTDIR"
File "setup.exe"
Exec "$INSTDIR\setup.exe"
BringToFront
SectionEnd
我是 NSIS 的新手,我正在尝试在安装时执行可执行文件,类似于预请求。我尝试了下面的代码,它将 exe 复制到安装路径,但它没有执行它。
Section "example" example
SetOutPath "$INSTDIR"
File "setup.exe"
Exec "$INSTDIR\setup.exe"
BringToFront
SectionEnd
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:
变量是否$INSTDIR
映射到名称包含空格的目录?如果是这样,您应该添加简单引号以将双引号包含到Exec
参数中:
Exec '"$INSTDIR\setup.exe"'