Search code examples
electronnsiselectron-builderappdata

Remove appData after uninstall Electron app


I want to remove the appData after my app was uninstalled.
The deleteAppDataOnUninstall: true option was useful when i run the uninstaller.exe,but not work when i install the app again.
When I want to install a version v2 to cover the version v1 existed in computer,i want to remove appData and create a new one.
I use the include: installer.nsh to do this.

!macro customInstall
  RMDir /r "$APPDATA\${APP_PACKAGE_NAME}"
!macroend

But the question is:
$APPDATAvariable in nsis is C:\ProgramData,the appData path I got in Electron app.getPath('userData') is C:\Users\user\AppData\Roaming

What should I do to remove the appData folder got from app.getPath('userData')?


Solution

  • $AppData depends on the SetShellVarContext setting. In your case it has been set to all and this means you are doing a all users install and you should not really modify a users profile.

    If you want to ignore this advice then make sure you have v3.08 and use $USERAPPDATA.