electron下删除注册表
JiaoXin2005 3/15/2021 JavaScript
# 背景
在自动更新升级 11 的过程中,发现不会删除老版本的注册表。导致在 windows 下的卸载或更改程序
会出现两个版本的应用。
# 删除注册表
electron-builder 提供一个include (opens new window)选项,用于执行自定义 NSIS 的脚本。步骤:
- 先自定义好删除注册表的脚本
- nsis 的配置中启用
uninstall.ns:
!macro customInit
DeleteRegKey HKLM "SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{e2371ebd-7734-58dc-97bd-f6c9d997b351}"
!macroend
1
2
3
2
3
package.json:
nsis: {
"guid": "e2371ebd-7734-58dc-97bd-f6c9d997b351",
"include": "resources/uninstall.nsh"
}
1
2
3
4
5
2
3
4
5
# guid (opens new window)
由于历史原因没指定过 guid,但是 appId 是不变的。这里可以写死 guid。