VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/Installer/VBoxGuestAdditionsUninstallOld.nsh@ 96692

Last change on this file since 96692 was 96407, checked in by vboxsync, 22 months ago

scm copyright and license note update

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

© 2023 Oracle
ContactPrivacy policyTerms of Use