0

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')?

Axman6
  • 909
  • 5
  • 16
罗知晏
  • 3
  • 3

1 Answers1

0

$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.

Anders
  • 97,548
  • 12
  • 110
  • 164
  • Thanks for your answer,this is helpful for me! But I need at least 15 reputation to cast a vote... – 罗知晏 Apr 21 '22 at 02:19
  • In my app,`$installMode` is set to `all`,but I can't find where to set this option in `electron-builder`,maybe this is a sideeffect by another option? Even the `$installMode` is `all`,`app.getPath('appData')` still returns `C:\Users\user\AppData\Roaming`,maybe this is the real question. – 罗知晏 Apr 21 '22 at 02:35
  • Now I can set `SetShellVarContext current ` to get user appData path,but what will happen if I don't restore this variable in the end? – 罗知晏 Apr 21 '22 at 02:40
  • The default context is probably set by oneClick and perMachine electron settings. – Anders Apr 21 '22 at 10:12