简体   繁体   中英

nsis uninstaller not deleting registry for electron app - nsh script

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM