1Function un.onInit
2  !insertmacro check64BitAndSetRegView
3
4  ${IfNot} ${Silent}
5    !ifdef ONE_CLICK
6      MessageBox MB_OKCANCEL "$(areYouSureToUninstall)" IDOK +2
7      Quit
8
9      # one-click installer executes uninstall section in the silent mode, but we must show message dialog if silent mode was not explicitly set by user (using /S flag)
10      !insertmacro CHECK_APP_RUNNING
11      SetSilent silent
12    !endif
13  ${endIf}
14
15  !insertmacro initMultiUser
16
17  !ifmacrodef customUnInit
18    !insertmacro customUnInit
19  !endif
20FunctionEnd
21
22Section "un.install"
23  !ifndef ONE_CLICK
24    # for assisted installer we check it here to show progress
25    !insertmacro CHECK_APP_RUNNING
26  !endif
27
28  !insertmacro setLinkVars
29
30  ${ifNot} ${isKeepShortcuts}
31    WinShell::UninstAppUserModelId "${APP_ID}"
32
33    !ifndef DO_NOT_CREATE_DESKTOP_SHORTCUT
34      WinShell::UninstShortcut "$oldDesktopLink"
35      Delete "$oldDesktopLink"
36    !endif
37
38    !ifndef DO_NOT_CREATE_START_MENU_SHORTCUT
39      WinShell::UninstShortcut "$oldStartMenuLink"
40
41      Delete "$oldStartMenuLink"
42      ReadRegStr $R1 SHELL_CONTEXT "${INSTALL_REGISTRY_KEY}" MenuDirectory
43      ${ifNot} $R1 == ""
44        RMDir "$SMPROGRAMS\$R1"
45      ${endIf}
46    !endif
47  ${endIf}
48
49  # refresh the desktop
50  System::Call 'shell32::SHChangeNotify(i, i, i, i) v (0x08000000, 0, 0, 0)'
51
52  !ifmacrodef unregisterFileAssociations
53    !insertmacro unregisterFileAssociations
54  !endif
55
56  # delete the installed files
57  !ifmacrodef customRemoveFiles
58    !insertmacro customRemoveFiles
59  !else
60    RMDir /r $INSTDIR
61  !endif
62
63  Var /GLOBAL isDeleteAppData
64  StrCpy $isDeleteAppData "0"
65
66  ClearErrors
67  ${GetParameters} $R0
68  ${GetOptions} $R0 "--delete-app-data" $R1
69  ${if} ${Errors}
70    !ifdef DELETE_APP_DATA_ON_UNINSTALL
71      ${ifNot} ${isUpdated}
72        StrCpy $isDeleteAppData "1"
73      ${endif}
74    !endif
75  ${else}
76    StrCpy $isDeleteAppData "1"
77  ${endIf}
78
79  ${if} $isDeleteAppData == "1"
80    # electron always uses per user app data
81    ${if} $installMode == "all"
82      SetShellVarContext current
83    ${endif}
84    RMDir /r "$APPDATA\${APP_FILENAME}"
85    !ifdef APP_PRODUCT_FILENAME
86      RMDir /r "$APPDATA\${APP_PRODUCT_FILENAME}"
87    !endif
88    # electron use package.json name for cache,indexdb etc.
89    !ifdef APP_PACKAGE_NAME
90      RMDir /r "$APPDATA\${APP_PACKAGE_NAME}"
91    !endif
92    ${if} $installMode == "all"
93      SetShellVarContext all
94    ${endif}
95  ${endif}
96
97  DeleteRegKey SHELL_CONTEXT "${UNINSTALL_REGISTRY_KEY}"
98  !ifdef UNINSTALL_REGISTRY_KEY_2
99    DeleteRegKey SHELL_CONTEXT "${UNINSTALL_REGISTRY_KEY_2}"
100  !endif
101  DeleteRegKey SHELL_CONTEXT "${INSTALL_REGISTRY_KEY}"
102
103  !ifmacrodef customUnInstall
104    !insertmacro customUnInstall
105  !endif
106
107  !ifdef ONE_CLICK
108    !insertmacro quitSuccess
109  !endif
110SectionEnd
111