E不小心

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

需求,想要的功能

  • 默认 Program Files 或 Program Files(x86)
  • 可以选择安装目录
  • 安装后自动运行程序

electorn-builder nsis 配置,如下:

{
    oneClick: false,
    perMachine: true,
    allowElevation: true,
    allowToChangeInstallationDirectory: true,
}

问题

脚本 (installer.nsh)

!macro customFinishPage
AutoCloseWindow true
Function StartApp
    ${if} ${isUpdated}
      StrCpy $1 "--updated"
    ${else}
      StrCpy $1 ""
    ${endif}
    ${StdUtils.ExecShellAsUser} $0 "$launchLink" "open" "$1"
FunctionEnd

Function .onInstSuccess
    Call StartApp
FunctionEnd

!macroend

把上面的脚本默认放到 build/install.nsh 中,重新打包,就可以了。

posted on 2021-11-02 11:52  E不小心  阅读(1731)  评论(0编辑  收藏  举报