在安装期间将带有电子生成器的 NSIS 脚本添加到 运行 DPInst.exe

Add NSIS script with electron builder to run DPInst.exe during install

我正在使用 electron-builder 为我的电子应用程序创建 NSIS Windows 安装程序。在安装过程中,我需要 运行 包含的 DPInst.exe 以确保安装驱动程序。

我可以告诉 electron-builder 不是我包含自定义脚本:

"nsis": {
  "include": "build/installer.nsh"
}

但我不知道 installer.nsh

中应该包含什么

文档说我需要这样的东西:

!macro customInstall
  !system "echo '' > ${BUILD_RESOURCES_DIR}/customInstall"
!macroend

而且我看到一些 NSIS 命令 运行 DPInst.exe

ExecWait '"$INSTDIR\resources\DPInst.exe" /sw'

但我不确定如何组合它们,因为我无法计算出语法!

嗯,这很明显 ‍♂️。我只需要将两者结合起来:

!macro customInstall
  ExecWait '"$INSTDIR\resources\DPInst.exe" /sw'
!macroend

对我来说,由于权限问题,ExecWait '"$INSTDIR\resources\DPInst.exe" /sw' 无法正常工作。

我必须添加 RequestExecutionLevel admin

installer.nsh 看起来像 -

!macro customHeader
    RequestExecutionLevel admin
!macroend
!macro customInstall   
  ExecWait '"$INSTDIR\ABC_Setup.exe" /sw'
!macroend