electron-builder nsis在安装过程中运行其他可执行文件

问题描述 投票:0回答:1

我正在尝试在我的应用安装过程中运行其他可执行文件,但找不到正确的路径来执行此操作。该程序添加有以下electron-builder配置:

extraFiles:
    -   from: tools/tapinstall/${arch}/
        to: resources/tapinstall/
        filter:
            - "**/*"

安装我的应用程序后,我可以在resources/tapinstall/文件夹中看到文件,因此正在移植。现在,在我的nsis installer.nsh中添加了ExecWait指令以从该目录运行exe,但失败。

作为一种绝望的措施,我认为在所有内容前都加$INSTDIR是不正确的举动,也许路径不是$INSTDIR等,我发现了3种可能的候选方法:

  • $INSTDIR
  • $APPDATA
  • $BUILD_RESOURCES_DIR

我添加了这个简单的代码来查看创建了哪个文件,因此我可以找出要使用的正确宏:

!macro customHeader
    RequestExecutionLevel admin
!macroend

!macro customInstall
    !system "echo 'as' > $INSTDIR/customInstall"
    !system "echo 'bs' > $APPDATA/customInstall"
    !system "echo 'cs' > $BUILD_RESOURCES_DIR/customInstall"

    ${ifNot} ${isUpdated}
        !system "echo 'a' > $INSTDIR/customInstall"
            !system "echo 'b' > $APPDATA/customInstall"
            !system "echo 'c' > $BUILD_RESOURCES_DIR/customInstall"
    ${endIf}
!macroend

然后,我在计算机上进行了完全搜索,找到了名为customInstall的文件...什么都没有。我在做什么错?

electron nsis electron-builder
1个回答
0
投票

!system(和所有其他!指令)在makensis.exe内的编译时执行。您不能在编译时访问变量/常量,只能定义和环境变量。

!define foo "Hello"
!warning "${NSISDIR} & $%Temp% & ${foo}"

Var Bar
Section
StrCpy $Bar "World"
MessageBox mb_ok "$InstDir & $Bar"
SectionEnd
© www.soinside.com 2019 - 2024. All rights reserved.