@@ -105,6 +105,36 @@ Var /GLOBAL isTryToKeepShortcuts
105
105
${endif}
106
106
!macroend
107
107
108
+ Function handleUninstallResult
109
+ Var /GLOBAL rootKey_uninstallResult
110
+ Exch $rootKey_uninstallResult
111
+
112
+ ${if} " $rootKey_uninstallResult" == " SHELL_CONTEXT"
113
+ !ifmacrodef customUnInstallCheck
114
+ !insertmacro customUnInstallCheck
115
+ Return
116
+ !endif
117
+ ${elseif} " $rootKey_uninstallResult" == " HKEY_CURRENT_USER"
118
+ !ifmacrodef customUnInstallCheckCurrentUser
119
+ !insertmacro customUnInstallCheckCurrentUser
120
+ Return
121
+ !endif
122
+ ${endif}
123
+
124
+ IfErrors 0 +3
125
+ DetailPrint ` Uninstall was not successful. Not able to launch uninstaller!`
126
+ Return
127
+
128
+ ${if} $R0 != 0
129
+ DetailPrint ` Uninstall was not successful. Uninstaller error code: $R0.`
130
+ ${endif}
131
+ FunctionEnd
132
+
133
+ !macro handleUninstallResult ROOT_KEY
134
+ Push " ${ROOT_KEY}"
135
+ Call handleUninstallResult
136
+ !macroend
137
+
108
138
# http://stackoverflow.com/questions/24595887/waiting-for-nsis-uninstaller-to-finish-in-nsis-installer-either-fails-or-the-uni
109
139
Function uninstallOldVersion
110
140
Var /GLOBAL uninstallerFileName
@@ -116,12 +146,16 @@ Function uninstallOldVersion
116
146
ClearErrors
117
147
Exch $rootKey
118
148
149
+ Push 0
150
+ Pop $R0
151
+
119
152
!insertmacro readReg $uninstallString " $rootKey" " ${UNINSTALL_REGISTRY_KEY}" UninstallString
120
153
${if} $uninstallString == " "
121
154
!ifdef UNINSTALL_REGISTRY_KEY_2
122
155
!insertmacro readReg $uninstallString " $rootKey" " ${UNINSTALL_REGISTRY_KEY_2}" UninstallString
123
156
!endif
124
157
${if} $uninstallString == " "
158
+ ClearErrors
125
159
Goto Done
126
160
${endif}
127
161
${endif}
@@ -140,6 +174,7 @@ Function uninstallOldVersion
140
174
141
175
${if} $installationDir == " "
142
176
${andIf} $uninstallerFileName == " "
177
+ ClearErrors
143
178
Goto Done
144
179
${endif}
145
180
@@ -172,17 +207,10 @@ Function uninstallOldVersion
172
207
!insertmacro copyFile " $uninstallerFileName" " $uninstallerFileNameTemp"
173
208
174
209
ExecWait ' "$uninstallerFileNameTemp" /S /KEEP_APP_DATA $0 _?=$installationDir' $R0
175
- ifErrors 0 ExecErrorHandler
210
+ ifErrors 0 Done
176
211
# the execution failed - might have been caused by some group policy restrictions
177
212
# we try to execute the uninstaller in place
178
213
ExecWait ' "$uninstallerFileName" /S /KEEP_APP_DATA $0 _?=$installationDir' $R0
179
- ifErrors 0 ExecErrorHandler
180
- # this also failed...
181
- DetailPrint ` Aborting, uninstall was not successful. Not able to launch uninstaller!`
182
- ExecErrorHandler:
183
- ${if} $R0 != 0
184
- DetailPrint ` Aborting, uninstall was not successful. Uninstaller error code: $R0.`
185
- ${endif}
186
214
Done:
187
215
FunctionEnd
188
216
0 commit comments