[NSH]Electron Builder中安装第三方软件

Electron Builder支持NSIS格式输出构建产物。NSIS可以使用NSH来定制安装过程,以下为安装VC Redist示例:

!macro customHeader 
  ;vc redist需要管理员权限
  RequestExecutionLevel admin
!macroend

!macro customInstall
  ; install vc-redist if not installed
  ReadRegStr $1 HKLM "SOFTWARE\WOW6432Node\Microsoft\VisualStudio\14.0\VC\Runtimes\x64" "Installed"
  StrCmp $1 1 installed

  ;not installed, so run the installer
  ;这是在安装的过程中执行,所以需要打包的时候把安装包提前集成进来,或者从网络下载
  ExecWait '"$INSTDIR\resources\VcRedist\2022\14.38.33135.0\x64\VC_redist.x64.exe" /install /quiet /norestart'

  installed:
  ;we are done
!macroend

对应的electron-builder.json配置项

{
  "nsis": {
    "include": "vc-redist/install-vcredist.nsh"
  }
}
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容