问题
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