1 | ;*
|
---|
2 | ;* @file
|
---|
3 | ;* VBoxGuestAdditionsUninstallOld.nsh - Guest Additions uninstallation handling
|
---|
4 | ;* for legacy packages.
|
---|
5 | ;*
|
---|
6 |
|
---|
7 | ;*
|
---|
8 | ;* Copyright (C) 2011 Oracle Corporation
|
---|
9 | ;*
|
---|
10 | ;* This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
11 | ;* available from http://www.virtualbox.org. This file is free software;
|
---|
12 | ;* you can redistribute it and/or modify it under the terms of the GNU
|
---|
13 | ;* General Public License (GPL) as published by the Free Software
|
---|
14 | ;* Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
15 | ;* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
16 | ;* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
17 | ;*
|
---|
18 |
|
---|
19 | !macro Uninstall_RunExtUnInstaller un
|
---|
20 | Function ${un}Uninstall_RunExtUnInstaller
|
---|
21 |
|
---|
22 | Pop $0
|
---|
23 | Push $1
|
---|
24 | Push $2
|
---|
25 |
|
---|
26 | ; Try to run the current uninstaller
|
---|
27 | StrCpy $1 "$0\uninst.exe"
|
---|
28 | IfFileExists "$1" run 0
|
---|
29 | MessageBox MB_OK "VirtualBox Guest Additions uninstaller not found! Path = $1" /SD IDOK
|
---|
30 | StrCpy $0 1 ; Tell the caller that we were not able to start the uninstaller
|
---|
31 | Goto exit
|
---|
32 |
|
---|
33 | run:
|
---|
34 |
|
---|
35 | ; Always try to run in silent mode
|
---|
36 | Goto run_uninst_silent
|
---|
37 |
|
---|
38 | run_uninst_silent:
|
---|
39 |
|
---|
40 | ExecWait '"$1" /S _?=$0' $2 ; Silently run uninst.exe in it's dir and don't copy it to a temp. location
|
---|
41 | Goto handle_result
|
---|
42 |
|
---|
43 | run_uninst:
|
---|
44 |
|
---|
45 | ExecWait '"$1" _?=$0' $2 ; Run uninst.exe in it's dir and don't copy it to a temp. location
|
---|
46 | Goto handle_result
|
---|
47 |
|
---|
48 | handle_result:
|
---|
49 |
|
---|
50 | ; Note that here a race might going on after the user clicked on
|
---|
51 | ; "Reboot now" in the installer ran above and this installer cleaning
|
---|
52 | ; up afterwards
|
---|
53 |
|
---|
54 | ; ... so try to abort the current reboot / shutdown caused by the installer ran before
|
---|
55 | Call ${un}AbortShutdown
|
---|
56 |
|
---|
57 | ;!ifdef _DEBUG
|
---|
58 | ; MessageBox MB_OK 'Debug Message: Uninstaller was called, result is: $2' /SD IDOK
|
---|
59 | ;!endif
|
---|
60 |
|
---|
61 | ${Switch} $2 ; Check exit codes
|
---|
62 | ${Case} 1 ; Aborted by user
|
---|
63 | StrCpy $0 1 ; Tell the caller that we were aborted by the user
|
---|
64 | ${Break}
|
---|
65 | ${Case} 2 ; Aborted by script (that might be okay)
|
---|
66 | StrCpy $0 0 ; All went well
|
---|
67 | ${Break}
|
---|
68 | ${Default} ; Normal exixt
|
---|
69 | StrCpy $0 0 ; All went well
|
---|
70 | ${Break}
|
---|
71 | ${EndSwitch}
|
---|
72 | Goto exit
|
---|
73 |
|
---|
74 | exit:
|
---|
75 |
|
---|
76 | Pop $2
|
---|
77 | Pop $1
|
---|
78 | Push $0
|
---|
79 |
|
---|
80 | FunctionEnd
|
---|
81 | !macroend
|
---|
82 | !insertmacro Uninstall_RunExtUnInstaller ""
|
---|
83 | !insertmacro Uninstall_RunExtUnInstaller "un."
|
---|
84 |
|
---|
85 | !macro Uninstall_WipeInstallationDirectory un
|
---|
86 | Function ${un}Uninstall_WipeInstallationDirectory
|
---|
87 |
|
---|
88 | Pop $0
|
---|
89 | Push $1
|
---|
90 | Push $2
|
---|
91 |
|
---|
92 | ; Do some basic sanity checks for not screwing up too fatal ...
|
---|
93 | DetailPrint "Removing old installation directory ($0) ..."
|
---|
94 | ${If} $0 != $PROGRAMFILES
|
---|
95 | ${AndIf} $0 != $PROGRAMFILES32
|
---|
96 | ${AndIf} $0 != $PROGRAMFILES64
|
---|
97 | ${AndIf} $0 != $COMMONFILES32
|
---|
98 | ${AndIf} $0 != $COMMONFILES64
|
---|
99 | ${AndIf} $0 != $WINDIR
|
---|
100 | ${AndIf} $0 != $SYSDIR
|
---|
101 | DetailPrint "Wiping ($0) ..."
|
---|
102 | Goto wipe
|
---|
103 | ${EndIf}
|
---|
104 | Goto wipe_abort
|
---|
105 |
|
---|
106 | wipe:
|
---|
107 |
|
---|
108 | RMDir /r /REBOOTOK "$0"
|
---|
109 | StrCpy $0 0 ; All went well
|
---|
110 | Goto exit
|
---|
111 |
|
---|
112 | wipe_abort:
|
---|
113 |
|
---|
114 | DetailPrint "Won't remove directory ($0)!"
|
---|
115 | StrCpy $0 1 ; Signal some failure
|
---|
116 | Goto exit
|
---|
117 |
|
---|
118 | exit:
|
---|
119 |
|
---|
120 | Pop $2
|
---|
121 | Pop $1
|
---|
122 | Push $0
|
---|
123 |
|
---|
124 | FunctionEnd
|
---|
125 | !macroend
|
---|
126 | !insertmacro Uninstall_WipeInstallationDirectory ""
|
---|
127 | !insertmacro Uninstall_WipeInstallationDirectory "un."
|
---|
128 |
|
---|
129 | ; This function cleans up an old Sun installation
|
---|
130 | !macro Uninstall_Sun un
|
---|
131 | Function ${un}Uninstall_Sun
|
---|
132 |
|
---|
133 | Push $0
|
---|
134 | Push $1
|
---|
135 | Push $2
|
---|
136 |
|
---|
137 | ; Get current installation path
|
---|
138 | ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Sun VirtualBox Guest Additions" "UninstallString"
|
---|
139 | StrCmp $0 "" exit
|
---|
140 |
|
---|
141 | ; Extract path
|
---|
142 | Push "$0" ; String
|
---|
143 | Push "\" ; SubString
|
---|
144 | Push "<" ; SearchDirection
|
---|
145 | Push "<" ; StrInclusionDirection
|
---|
146 | Push "0" ; IncludeSubString
|
---|
147 | Push "0" ; Loops
|
---|
148 | Push "0" ; CaseSensitive
|
---|
149 | Call ${un}StrStrAdv
|
---|
150 | Pop $1 ; $1 only contains the full path
|
---|
151 |
|
---|
152 | StrCmp $1 "" exit
|
---|
153 |
|
---|
154 | ; Save current i8042prt info to new uninstall registry path
|
---|
155 | ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Sun VirtualBox Guest Additions" ${ORG_MOUSE_PATH}
|
---|
156 | WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" ${ORG_MOUSE_PATH} $0
|
---|
157 |
|
---|
158 | ; Try to wipe current installation directory
|
---|
159 | Push $1 ; Push uninstaller path to stack
|
---|
160 | Call ${un}Uninstall_WipeInstallationDirectory
|
---|
161 | Pop $2 ; Get uninstaller exit code from stack
|
---|
162 | StrCmp $2 0 common exit ; Only process common part if exit code is 0, otherwise exit
|
---|
163 |
|
---|
164 | common:
|
---|
165 |
|
---|
166 | ; Make sure everything is cleaned up in case the old uninstaller did forget something
|
---|
167 | DeleteRegKey HKLM "SOFTWARE\Sun\VirtualBox Guest Additions"
|
---|
168 | DeleteRegKey /ifempty HKLM "SOFTWARE\Sun"
|
---|
169 | DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Sun VirtualBox Guest Additions"
|
---|
170 | Delete /REBOOTOK "$1\netamd.inf"
|
---|
171 | Delete /REBOOTOK "$1\pcntpci5.cat"
|
---|
172 | Delete /REBOOTOK "$1\PCNTPCI5.sys"
|
---|
173 |
|
---|
174 | ; Try to remove old installation directory if empty
|
---|
175 | RMDir /r /REBOOTOK "$SMPROGRAMS\Sun VirtualBox Guest Additions"
|
---|
176 | RMDir /REBOOTOK "$1"
|
---|
177 |
|
---|
178 | ; Get original mouse driver info and restore it
|
---|
179 | ;ReadRegStr $0 ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" ${ORG_MOUSE_PATH}
|
---|
180 | ;WriteRegStr HKLM "SYSTEM\CurrentControlSet\Services\i8042prt" "ImagePath" $0
|
---|
181 | ;Delete "$SYSDIR\drivers\VBoxMouseNT.sys"
|
---|
182 |
|
---|
183 | ; Delete vendor installation directory (only if completely empty)
|
---|
184 | !if $%BUILD_TARGET_ARCH% == "x86" ; 32-bit
|
---|
185 | RMDir /REBOOTOK "$PROGRAMFILES32\Sun"
|
---|
186 | !else ; 64-bit
|
---|
187 | RMDir /REBOOTOK "$PROGRAMFILES64\Sun"
|
---|
188 | !endif
|
---|
189 |
|
---|
190 | exit:
|
---|
191 |
|
---|
192 | Pop $2
|
---|
193 | Pop $1
|
---|
194 | Pop $0
|
---|
195 |
|
---|
196 | FunctionEnd
|
---|
197 | !macroend
|
---|
198 | !insertmacro Uninstall_Sun ""
|
---|
199 | !insertmacro Uninstall_Sun "un."
|
---|
200 |
|
---|
201 | ; This function cleans up an old xVM Sun installation
|
---|
202 | !macro Uninstall_SunXVM un
|
---|
203 | Function ${un}Uninstall_SunXVM
|
---|
204 |
|
---|
205 | Push $0
|
---|
206 | Push $1
|
---|
207 | Push $2
|
---|
208 |
|
---|
209 | ; Get current installation path
|
---|
210 | ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Sun xVM VirtualBox Guest Additions" "UninstallString"
|
---|
211 | StrCmp $0 "" exit
|
---|
212 |
|
---|
213 | ; Extract path
|
---|
214 | Push "$0" ; String
|
---|
215 | Push "\" ; SubString
|
---|
216 | Push "<" ; SearchDirection
|
---|
217 | Push "<" ; StrInclusionDirection
|
---|
218 | Push "0" ; IncludeSubString
|
---|
219 | Push "0" ; Loops
|
---|
220 | Push "0" ; CaseSensitive
|
---|
221 | Call ${un}StrStrAdv
|
---|
222 | Pop $1 ; $1 only contains the full path
|
---|
223 |
|
---|
224 | StrCmp $1 "" exit
|
---|
225 |
|
---|
226 | ; Save current i8042prt info to new uninstall registry path
|
---|
227 | ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Sun xVM VirtualBox Guest Additions" ${ORG_MOUSE_PATH}
|
---|
228 | WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" ${ORG_MOUSE_PATH} $0
|
---|
229 |
|
---|
230 | ; Try to wipe current installation directory
|
---|
231 | Push $1 ; Push uninstaller path to stack
|
---|
232 | Call ${un}Uninstall_WipeInstallationDirectory
|
---|
233 | Pop $2 ; Get uninstaller exit code from stack
|
---|
234 | StrCmp $2 0 common exit ; Only process common part if exit code is 0, otherwise exit
|
---|
235 |
|
---|
236 | common:
|
---|
237 |
|
---|
238 | ; Make sure everything is cleaned up in case the old uninstaller did forget something
|
---|
239 | DeleteRegKey HKLM "SOFTWARE\Sun\xVM VirtualBox Guest Additions"
|
---|
240 | DeleteRegKey /ifempty HKLM "SOFTWARE\Sun"
|
---|
241 | DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Sun xVM VirtualBox Guest Additions"
|
---|
242 | Delete /REBOOTOK "$1\netamd.inf"
|
---|
243 | Delete /REBOOTOK "$1\pcntpci5.cat"
|
---|
244 | Delete /REBOOTOK "$1\PCNTPCI5.sys"
|
---|
245 |
|
---|
246 | ; Try to remove old installation directory if empty
|
---|
247 | RMDir /r /REBOOTOK "$SMPROGRAMS\Sun xVM VirtualBox Guest Additions"
|
---|
248 | RMDir /REBOOTOK "$1"
|
---|
249 |
|
---|
250 | ; Delete vendor installation directory (only if completely empty)
|
---|
251 | !if $%BUILD_TARGET_ARCH% == "x86" ; 32-bit
|
---|
252 | RMDir /REBOOTOK "$PROGRAMFILES32\Sun"
|
---|
253 | !else ; 64-bit
|
---|
254 | RMDir /REBOOTOK "$PROGRAMFILES64\Sun"
|
---|
255 | !endif
|
---|
256 |
|
---|
257 | ; Get original mouse driver info and restore it
|
---|
258 | ;ReadRegStr $0 ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" ${ORG_MOUSE_PATH}
|
---|
259 | ;WriteRegStr HKLM "SYSTEM\CurrentControlSet\Services\i8042prt" "ImagePath" $0
|
---|
260 | ;Delete "$SYSDIR\drivers\VBoxMouseNT.sys"
|
---|
261 |
|
---|
262 | exit:
|
---|
263 |
|
---|
264 | Pop $2
|
---|
265 | Pop $1
|
---|
266 | Pop $0
|
---|
267 |
|
---|
268 | FunctionEnd
|
---|
269 | !macroend
|
---|
270 | !insertmacro Uninstall_SunXVM ""
|
---|
271 | !insertmacro Uninstall_SunXVM "un."
|
---|
272 |
|
---|
273 | ; This function cleans up an old innotek installation
|
---|
274 | !macro Uninstall_Innotek un
|
---|
275 | Function ${un}Uninstall_Innotek
|
---|
276 |
|
---|
277 | Push $0
|
---|
278 | Push $1
|
---|
279 | Push $2
|
---|
280 |
|
---|
281 | ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\innotek VirtualBox Guest Additions" "UninstallString"
|
---|
282 | StrCmp $0 "" exit
|
---|
283 |
|
---|
284 | ; Extract path
|
---|
285 | Push "$0" ; String
|
---|
286 | Push "\" ; SubString
|
---|
287 | Push "<" ; SearchDirection
|
---|
288 | Push "<" ; StrInclusionDirection
|
---|
289 | Push "0" ; IncludeSubString
|
---|
290 | Push "0" ; Loops
|
---|
291 | Push "0" ; CaseSensitive
|
---|
292 | Call ${un}StrStrAdv
|
---|
293 | Pop $1 ; $1 only contains the full path
|
---|
294 |
|
---|
295 | StrCmp $1 "" exit
|
---|
296 |
|
---|
297 | ; Save current i8042prt info to new uninstall registry path
|
---|
298 | ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\innotek VirtualBox Guest Additions" ${ORG_MOUSE_PATH}
|
---|
299 | WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" ${ORG_MOUSE_PATH} $0
|
---|
300 |
|
---|
301 | ; Try to wipe current installation directory
|
---|
302 | Push $1 ; Push uninstaller path to stack
|
---|
303 | Call ${un}Uninstall_WipeInstallationDirectory
|
---|
304 | Pop $2 ; Get uninstaller exit code from stack
|
---|
305 | StrCmp $2 0 common exit ; Only process common part if exit code is 0, otherwise exit
|
---|
306 |
|
---|
307 | common:
|
---|
308 |
|
---|
309 | ; Remove left over files which were not entirely cached by the formerly running
|
---|
310 | ; uninstaller
|
---|
311 | DeleteRegKey HKLM "SOFTWARE\innotek\VirtualBox Guest Additions"
|
---|
312 | DeleteRegKey HKLM "SOFTWARE\innotek"
|
---|
313 | DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\innotek VirtualBox Guest Additions"
|
---|
314 | Delete /REBOOTOK "$1\VBoxGuestDrvInst.exe"
|
---|
315 | Delete /REBOOTOK "$1\VBoxMouseInst.exe"
|
---|
316 | Delete /REBOOTOK "$1\VBoxSFDrvInst.exe"
|
---|
317 | Delete /REBOOTOK "$1\RegCleanup.exe"
|
---|
318 | Delete /REBOOTOK "$1\VBoxService.exe"
|
---|
319 | Delete /REBOOTOK "$1\VBoxMouseInst.exe"
|
---|
320 | Delete /REBOOTOK "$1\innotek VirtualBox Guest Additions.url"
|
---|
321 | Delete /REBOOTOK "$1\uninst.exe"
|
---|
322 | Delete /REBOOTOK "$1\iexplore.ico"
|
---|
323 | Delete /REBOOTOK "$1\install.log"
|
---|
324 | Delete /REBOOTOK "$1\VBCoInst.dll"
|
---|
325 | Delete /REBOOTOK "$1\VBoxControl.exe"
|
---|
326 | Delete /REBOOTOK "$1\VBoxDisp.dll"
|
---|
327 | Delete /REBOOTOK "$1\VBoxGINA.dll"
|
---|
328 | Delete /REBOOTOK "$1\VBoxGuest.cat"
|
---|
329 | Delete /REBOOTOK "$1\VBoxGuest.inf"
|
---|
330 | Delete /REBOOTOK "$1\VBoxGuest.sys"
|
---|
331 | Delete /REBOOTOK "$1\VBoxMouse.inf"
|
---|
332 | Delete /REBOOTOK "$1\VBoxMouse.sys"
|
---|
333 | Delete /REBOOTOK "$1\VBoxVideo.cat"
|
---|
334 | Delete /REBOOTOK "$1\VBoxVideo.inf"
|
---|
335 | Delete /REBOOTOK "$1\VBoxVideo.sys"
|
---|
336 |
|
---|
337 | ; Try to remove old installation directory if empty
|
---|
338 | RMDir /r /REBOOTOK "$SMPROGRAMS\innotek VirtualBox Guest Additions"
|
---|
339 | RMDir /REBOOTOK "$1"
|
---|
340 |
|
---|
341 | ; Delete vendor installation directory (only if completely empty)
|
---|
342 | !if $%BUILD_TARGET_ARCH% == "x86" ; 32-bit
|
---|
343 | RMDir /REBOOTOK "$PROGRAMFILES32\innotek"
|
---|
344 | !else ; 64-bit
|
---|
345 | RMDir /REBOOTOK "$PROGRAMFILES64\innotek"
|
---|
346 | !endif
|
---|
347 |
|
---|
348 | ; Get original mouse driver info and restore it
|
---|
349 | ;ReadRegStr $0 ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" ${ORG_MOUSE_PATH}
|
---|
350 | ;WriteRegStr HKLM "SYSTEM\CurrentControlSet\Services\i8042prt" "ImagePath" $0
|
---|
351 | ;Delete "$SYSDIR\drivers\VBoxMouseNT.sys"
|
---|
352 |
|
---|
353 | exit:
|
---|
354 |
|
---|
355 | Pop $2
|
---|
356 | Pop $1
|
---|
357 | Pop $0
|
---|
358 |
|
---|
359 | FunctionEnd
|
---|
360 | !macroend
|
---|
361 | !insertmacro Uninstall_Innotek ""
|
---|
362 | !insertmacro Uninstall_Innotek "un."
|
---|