nsis uninstaller not deleting registry for electron app - nsh script

我怕爱的太早我们不能终老 提交于 2019-12-25 00:14:43

问题


I've set my electron app to auto-start on windows:

app.setLoginItemSettings({
    openAtLogin: true,
    path: process.execPaths
})

This adds an entry to registry at location Computer\HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run\electron.app my app

I'm using electron-builder to package my app.

It's mention there that I can add a script installer.nsh at the time of nsis uninstallation.

Here's my custom installer.nsh:

!macro customUnInstall
    SetRegView 64
     DeleteRegKey /ifempty SHCTX "Software\Microsoft\Windows\CurrentVersion\Run\electron.app.my app"
    SetRegView 32
     DeleteRegKey /ifempty SHCTX "Software\Microsoft\Windows\CurrentVersion\Run\electron.app.my app"
 !macroend

And lastly, I mentioned it in package.json:

"nsis": {
      "runAfterFinish": true,
      "createDesktopShortcut": true,
      "deleteAppDataOnUninstall": true,
      "include": "build/installer.nsh"
    }

But, still when I uninstall my app the entry is left in the registry.

How to remove this entry?


回答1:


DeleteRegKey deletes keys but I'm guessing your run entry is actually a value. Use DeleteRegValue to delete values:

DeleteRegValue HKCU "Software\Microsoft\Windows\CurrentVersion\Run" "electron.app my app"

Why are you using SHCTX? Use HKCU if you know it is always written to HKEY_CURRENT_USER.



来源:https://stackoverflow.com/questions/47210665/nsis-uninstaller-not-deleting-registry-for-electron-app-nsh-script

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!